aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc.go2
-rw-r--r--sqlite3_go113_test.go4
-rw-r--r--sqlite3_test.go30
3 files changed, 5 insertions, 31 deletions
diff --git a/doc.go b/doc.go
index 7a4fb6d..ac27633 100644
--- a/doc.go
+++ b/doc.go
@@ -90,7 +90,7 @@ ConnectHook to get the SQLiteConn.
},
})
-You can also use database/sql.Conn.Raw:
+You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background())
// if err != nil { ... }
diff --git a/sqlite3_go113_test.go b/sqlite3_go113_test.go
index 74036f8..6f74e6b 100644
--- a/sqlite3_go113_test.go
+++ b/sqlite3_go113_test.go
@@ -49,6 +49,10 @@ func TestBeginTxCancel(t *testing.T) {
if !ok {
t.Fatal("unexpected: wrong type")
}
+ // checks that conn.Raw can be used to get *SQLiteConn
+ if _, ok = driverConn.(*SQLiteConn); !ok {
+ t.Fatalf("conn.Raw() driverConn type=%T, expected *SQLiteConn", driverConn)
+ }
go cancel() // make it cancel concurrently with exec("BEGIN");
tx, err := d.BeginTx(ctx, driver.TxOptions{})
diff --git a/sqlite3_test.go b/sqlite3_test.go
index fe367cf..d5b0cea 100644
--- a/sqlite3_test.go
+++ b/sqlite3_test.go
@@ -9,7 +9,6 @@ package sqlite3
import (
"bytes"
- "context"
"database/sql"
"database/sql/driver"
"errors"
@@ -2353,32 +2352,3 @@ func benchmarkStmtRows(b *testing.B) {
}
}
}
-
-func TestConnRawIsSQLiteConn(t *testing.T) {
- db, err := sql.Open("sqlite3", ":memory:")
- if err != nil {
- t.Fatal("Failed to open db:", err)
- }
- defer db.Close()
-
- conn, err := db.Conn(context.Background())
- if err != nil {
- t.Fatal("Failed to get conn:", err)
- }
- defer conn.Close()
- err = conn.Raw(func(driverConn interface{}) error {
- sqliteConn, ok := driverConn.(*SQLiteConn)
- if !ok {
- t.Errorf("driverConn type=%T; expected to be *SQLiteConn", driverConn)
- return nil
- }
- // call a private SQLite API to confirm the raw conn "works"
- if sqliteConn.AuthEnabled() {
- t.Error("sqliteConn.AuthEnabled()=true; expected false")
- }
- return nil
- })
- if err != nil {
- t.Error("conn.Raw() returned err:", err)
- }
-}