forked from mirror/gorm
Fix call valuer interface when using nil value
This commit is contained in:
parent
92d5a959a0
commit
45e804dd3f
|
@ -368,7 +368,7 @@ func (like Like) NegationBuild(builder Builder) {
|
|||
}
|
||||
|
||||
func eqNil(value interface{}) bool {
|
||||
if valuer, ok := value.(driver.Valuer); ok {
|
||||
if valuer, ok := value.(driver.Valuer); ok && !eqNilReflect(valuer) {
|
||||
value, _ = valuer.Value()
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,12 @@ func (stmt *Statement) AddVar(writer clause.Writer, vars ...interface{}) {
|
|||
case clause.Column, clause.Table:
|
||||
stmt.QuoteTo(writer, v)
|
||||
case Valuer:
|
||||
reflectValue := reflect.ValueOf(v)
|
||||
if reflectValue.Kind() == reflect.Ptr && reflectValue.IsNil() {
|
||||
stmt.AddVar(writer, nil)
|
||||
} else {
|
||||
stmt.AddVar(writer, v.GormValue(stmt.Context, stmt.DB))
|
||||
}
|
||||
case clause.Expr:
|
||||
v.Build(stmt)
|
||||
case *clause.Expr:
|
||||
|
|
Loading…
Reference in New Issue