代码拉取完成,页面将自动刷新
//go:build sqlite_column_metadata
// +build sqlite_column_metadata
package sqlite3
import "testing"
func TestColumnTableName(t *testing.T) {
d := SQLiteDriver{}
conn, err := d.Open(":memory:")
if err != nil {
t.Fatal("failed to get database connection:", err)
}
defer conn.Close()
sqlite3conn := conn.(*SQLiteConn)
_, err = sqlite3conn.Exec(`CREATE TABLE foo (name string)`, nil)
if err != nil {
t.Fatal("Failed to create table:", err)
}
_, err = sqlite3conn.Exec(`CREATE TABLE bar (name string)`, nil)
if err != nil {
t.Fatal("Failed to create table:", err)
}
stmt, err := sqlite3conn.Prepare(`SELECT * FROM foo JOIN bar ON foo.name = bar.name`)
if err != nil {
t.Fatal(err)
}
if exp, got := "foo", stmt.(*SQLiteStmt).ColumnTableName(0); exp != got {
t.Fatalf("Incorrect table name returned expected: %s, got: %s", exp, got)
}
if exp, got := "bar", stmt.(*SQLiteStmt).ColumnTableName(1); exp != got {
t.Fatalf("Incorrect table name returned expected: %s, got: %s", exp, got)
}
if exp, got := "", stmt.(*SQLiteStmt).ColumnTableName(2); exp != got {
t.Fatalf("Incorrect table name returned expected: %s, got: %s", exp, got)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。