mirror of
https://github.com/hanzoai/csqlite.git
synced 2026-10-30 18:42:02 +00:00
Fork of github.com/mattn/go-sqlite3 v1.14.47, rebranded to package csqlite and vendored in-tree (SQLite amalgamation sqlite3-binding.c/.h + cgo driver + callback trampolines + optional-feature files) so the Hanzo stack depends on no external go-sqlite3 module. Registers the "sqlite3" database/sql driver name from this repo. SQLCipher at-rest encryption unchanged: link system libsqlcipher via -tags libsqlite3. Preserves upstream MIT license (LICENSE) with Hanzo-first NOTICE attribution. Verified: CGO_ENABLED=1 build+test (amalgamation) green; -tags libsqlite3 + libsqlcipher build+test green; CGO_ENABLED=0 build green; zero mattn in deps.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
//go:build sqlite_column_metadata
|
|
// +build sqlite_column_metadata
|
|
|
|
package csqlite
|
|
|
|
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)
|
|
}
|
|
}
|