Support double ptr for Save

This commit is contained in:
Jinzhu 2022-04-08 14:23:25 +08:00
parent 81c4024232
commit 0729261b62
1 changed files with 4 additions and 0 deletions

View File

@ -74,6 +74,10 @@ func (db *DB) Save(value interface{}) (tx *DB) {
tx.Statement.Dest = value tx.Statement.Dest = value
reflectValue := reflect.Indirect(reflect.ValueOf(value)) reflectValue := reflect.Indirect(reflect.ValueOf(value))
for reflectValue.Kind() == reflect.Ptr || reflectValue.Kind() == reflect.Interface {
reflectValue = reflect.Indirect(reflectValue)
}
switch reflectValue.Kind() { switch reflectValue.Kind() {
case reflect.Slice, reflect.Array: case reflect.Slice, reflect.Array:
if _, ok := tx.Statement.Clauses["ON CONFLICT"]; !ok { if _, ok := tx.Statement.Clauses["ON CONFLICT"]; !ok {