File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1504,6 +1504,14 @@ func TestIssue197(t *testing.T) {
1504
1504
})
1505
1505
}
1506
1506
1507
+ type Valuer struct {
1508
+ Val string
1509
+ }
1510
+
1511
+ func (v Valuer ) Value () (driver.Value , error ) {
1512
+ return v .Val , nil
1513
+ }
1514
+
1507
1515
func TestIn (t * testing.T ) {
1508
1516
// some quite normal situations
1509
1517
type tr struct {
@@ -1538,6 +1546,24 @@ func TestIn(t *testing.T) {
1538
1546
}
1539
1547
}
1540
1548
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
+
1541
1567
// too many bindVars, but no slices, so short circuits parsing
1542
1568
// i'm not sure if this is the right behavior; this query/arg combo
1543
1569
// 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