File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1504,6 +1504,14 @@ func TestIssue197(t *testing.T) {
15041504 })
15051505}
15061506
1507+ type Valuer struct {
1508+ Val string
1509+ }
1510+
1511+ func (v Valuer ) Value () (driver.Value , error ) {
1512+ return v .Val , nil
1513+ }
1514+
15071515func TestIn (t * testing.T ) {
15081516 // some quite normal situations
15091517 type tr struct {
@@ -1538,6 +1546,24 @@ func TestIn(t *testing.T) {
15381546 }
15391547 }
15401548
1549+ // nil driver.Valuer
1550+ t .Run ("with nil driver.Valuer" , func (t * testing.T ) {
1551+ query := `SELECT * FROM foo WHERE x = ? or y IN (?)`
1552+ _ , _ , err := In (query ,
1553+ (* Valuer )(nil ), // a non-inited pointer to valuer
1554+ []interface {}{
1555+ "a" , // a usual value
1556+ nil , // a nil value
1557+ Valuer {Val : "foo" }, // a Valuer
1558+ & Valuer {Val : "foo" }, // a pointer to valuer
1559+ (* Valuer )(nil ), // a non-inited pointer to valuer
1560+ },
1561+ )
1562+ if err != nil {
1563+ t .Error (err )
1564+ }
1565+ })
1566+
15411567 // too many bindVars, but no slices, so short circuits parsing
15421568 // i'm not sure if this is the right behavior; this query/arg combo
15431569 // might not work, but we shouldn't parse if we don't need to
You can’t perform that action at this time.
0 commit comments