1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2024-11-16 17:41:57 +02:00

support for usage of sql.Out as a param value

This commit is contained in:
Kyril Revels 2019-06-04 17:57:33 -04:00
parent ef0bdf231a
commit 1dd355d63c
4 changed files with 32 additions and 5 deletions

2
go.mod
View File

@ -1 +1,3 @@
module github.com/DATA-DOG/go-sqlmock
go 1.12

View File

@ -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
}

11
sqlmock_go18_19.go Normal file
View File

@ -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
}

19
sqlmock_go19.go Normal file
View File

@ -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
}
}