forked from mirror/gorm
Allow to use Valuer with Eq expression, #3899
This commit is contained in:
parent
065787c54e
commit
6c0ee2700a
|
@ -301,6 +301,10 @@ func (like Like) NegationBuild(builder Builder) {
|
|||
}
|
||||
|
||||
func eqNil(value interface{}) bool {
|
||||
if valuer, ok := value.(driver.Valuer); ok {
|
||||
value, _ = valuer.Value()
|
||||
}
|
||||
|
||||
return value == nil || eqNilReflect(value)
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ func TestExpression(t *testing.T) {
|
|||
clause.Eq{Column: column, Value: (*int)(nil)},
|
||||
clause.Eq{Column: column, Value: (*bool)(nil)},
|
||||
clause.Eq{Column: column, Value: (interface{})(nil)},
|
||||
clause.Eq{Column: column, Value: sql.NullString{String: "", Valid: false}},
|
||||
},
|
||||
Result: "`column-name` IS NULL",
|
||||
}, {
|
||||
|
|
Loading…
Reference in New Issue