diff --git a/go.mod b/go.mod index eaf8a5a..0d598b0 100644 --- a/go.mod +++ b/go.mod @@ -1 +1,3 @@ module github.com/DATA-DOG/go-sqlmock + +go 1.12 diff --git a/sqlmock_go18.go b/sqlmock_go18.go index 0afb296..34509ff 100644 --- a/sqlmock_go18.go +++ b/sqlmock_go18.go @@ -114,8 +114,3 @@ func (stmt *statement) QueryContext(ctx context.Context, args []driver.NamedValu // @TODO maybe add ExpectedBegin.WithOptions(driver.TxOptions) -// CheckNamedValue meets https://golang.org/pkg/database/sql/driver/#NamedValueChecker -func (c *sqlmock) CheckNamedValue(nv *driver.NamedValue) (err error) { - nv.Value, err = c.converter.ConvertValue(nv.Value) - return err -} diff --git a/sqlmock_go18_19.go b/sqlmock_go18_19.go new file mode 100644 index 0000000..9d81a7f --- /dev/null +++ b/sqlmock_go18_19.go @@ -0,0 +1,11 @@ +// +build go1.8,!go1.9 + +package sqlmock + +import "database/sql/driver" + +// CheckNamedValue meets https://golang.org/pkg/database/sql/driver/#NamedValueChecker +func (c *sqlmock) CheckNamedValue(nv *driver.NamedValue) (err error) { + nv.Value, err = c.converter.ConvertValue(nv.Value) + return err +} diff --git a/sqlmock_go19.go b/sqlmock_go19.go new file mode 100644 index 0000000..c0f2424 --- /dev/null +++ b/sqlmock_go19.go @@ -0,0 +1,19 @@ +// +build go1.9 + +package sqlmock + +import ( + "database/sql" + "database/sql/driver" +) + +// CheckNamedValue meets https://golang.org/pkg/database/sql/driver/#NamedValueChecker +func (c *sqlmock) CheckNamedValue(nv *driver.NamedValue) (err error) { + switch nv.Value.(type) { + case sql.Out: + return nil + default: + nv.Value, err = c.converter.ConvertValue(nv.Value) + return err + } +}