From b1af04dedc3668d35a4e39ecf7f01d9b5332645c Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Wed, 27 Mar 2024 14:45:34 +0100 Subject: [PATCH 1/2] Merge CheckNamedValue into db.go AFAIK, there was never any need to hide this behind a build tag. Even less so now that we require Go 1.12 or newer per go.mod. --- db.go | 14 ++++++++++++++ db_go19.go | 22 ---------------------- 2 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 db_go19.go diff --git a/db.go b/db.go index bd08198..e561b97 100644 --- a/db.go +++ b/db.go @@ -367,6 +367,20 @@ func (c *conn) Query(query string, args []driver.Value) (driver.Rows, error) { return buildRows(rs) } +// Implement the NamedValueChecker interface +func (c *conn) CheckNamedValue(nv *driver.NamedValue) error { + if nvc, ok := c.drv.realConn.(driver.NamedValueChecker); ok { + return nvc.CheckNamedValue(nv) + } + + switch nv.Value.(type) { + case sql.Out: + return nil + default: + return driver.ErrSkip + } +} + type stmt struct { mu sync.Mutex st *sql.Stmt diff --git a/db_go19.go b/db_go19.go deleted file mode 100644 index 3c2f529..0000000 --- a/db_go19.go +++ /dev/null @@ -1,22 +0,0 @@ -// +build go1.9 - -package txdb - -import ( - "database/sql" - "database/sql/driver" -) - -// Implement the NamedValueChecker interface -func (c *conn) CheckNamedValue(nv *driver.NamedValue) error { - if nvc, ok := c.drv.realConn.(driver.NamedValueChecker); ok { - return nvc.CheckNamedValue(nv) - } - - switch nv.Value.(type) { - case sql.Out: - return nil - default: - return driver.ErrSkip - } -} From 3588446565848bb83ae9b0718aba3243d74cd4a9 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Wed, 27 Mar 2024 14:47:28 +0100 Subject: [PATCH 2/2] Drop pre-1.8 build tags/support --- db_go18.go => context.go | 2 -- db_before_go18.go | 14 -------------- 2 files changed, 16 deletions(-) rename db_go18.go => context.go (99%) delete mode 100644 db_before_go18.go diff --git a/db_go18.go b/context.go similarity index 99% rename from db_go18.go rename to context.go index 72cb390..e24f103 100644 --- a/db_go18.go +++ b/context.go @@ -1,5 +1,3 @@ -//go:build go1.8 - package txdb import ( diff --git a/db_before_go18.go b/db_before_go18.go deleted file mode 100644 index 291e240..0000000 --- a/db_before_go18.go +++ /dev/null @@ -1,14 +0,0 @@ -// +build !go1.8 - -package txdb - -import ( - "database/sql" - "database/sql/driver" -) - -func buildRows(r *sql.Rows) (driver.Rows, error) { - rows := &rows{} - err := rows.read(r) - return rows, err -}