aboutsummaryrefslogtreecommitdiff
path: root/sqlite3_test.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sqlite3_test.go42
1 files changed, 39 insertions, 3 deletions
diff --git a/sqlite3_test.go b/sqlite3_test.go
index 6570b52..aa86011 100644
--- a/sqlite3_test.go
+++ b/sqlite3_test.go
@@ -640,7 +640,7 @@ func TestTimezoneConversion(t *testing.T) {
zones := []string{"UTC", "US/Central", "US/Pacific", "Local"}
for _, tz := range zones {
tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename+"?loc="+url.QueryEscape(tz))
+ db, err := sql.Open("sqlite3", tempFilename+"?_loc="+url.QueryEscape(tz))
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -845,7 +845,7 @@ func TestStress(t *testing.T) {
func TestDateTimeLocal(t *testing.T) {
zone := "Asia/Tokyo"
tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename+"?loc="+zone)
+ db, err := sql.Open("sqlite3", tempFilename+"?_loc="+zone)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -888,7 +888,7 @@ func TestDateTimeLocal(t *testing.T) {
db.Exec("INSERT INTO foo VALUES(?);", dt)
db.Close()
- db, err = sql.Open("sqlite3", tempFilename+"?loc="+zone)
+ db, err = sql.Open("sqlite3", tempFilename+"?_loc="+zone)
if err != nil {
t.Fatal("Failed to open database:", err)
}
@@ -909,3 +909,39 @@ func TestVersion(t *testing.T) {
t.Errorf("Version failed %q, %d, %q\n", s, n, id)
}
}
+
+func TestNumberNamedParams(t *testing.T) {
+ tempFilename := TempFilename()
+ db, err := sql.Open("sqlite3", tempFilename)
+ if err != nil {
+ t.Fatal("Failed to open database:", err)
+ }
+ defer os.Remove(tempFilename)
+ defer db.Close()
+
+ _, err = db.Exec(`
+ create table foo (id integer, name text, extra text);
+ `)
+ if err != nil {
+ t.Error("Failed to call db.Query:", err)
+ }
+
+ _, err = db.Exec(`insert into foo(id, name, extra) values($1, $2, $2)`, 1, "foo")
+ if err != nil {
+ t.Error("Failed to call db.Exec:", err)
+ }
+
+ row := db.QueryRow(`select id, extra from foo where id = $1 and extra = $2`, 1, "foo")
+ if row == nil {
+ t.Error("Failed to call db.QueryRow")
+ }
+ var id int
+ var extra string
+ err = row.Scan(&id, &extra)
+ if err != nil {
+ t.Error("Failed to db.Scan:", err)
+ }
+ if id != 1 || extra != "foo" {
+ t.Error("Failed to db.QueryRow: not matched results")
+ }
+}