forked from mirror/gorm
Return error when creating with unaddressable record in postgres
This commit is contained in:
parent
d5d3e3a67b
commit
9edd66250e
|
@ -117,9 +117,13 @@ func createCallback(scope *Scope) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil {
|
if primaryField.Field.CanAddr() {
|
||||||
primaryField.IsBlank = false
|
if err := scope.SQLDB().QueryRow(scope.SQL, scope.SQLVars...).Scan(primaryField.Field.Addr().Interface()); scope.Err(err) == nil {
|
||||||
scope.db.RowsAffected = 1
|
primaryField.IsBlank = false
|
||||||
|
scope.db.RowsAffected = 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scope.Err(ErrUnaddressable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue