Merge 546069e74cef62c8f5a32c8146fcc6541b66f6e6 into 9acaa33324bbcc78239a1c913d4f1292c12177b9
This commit is contained in:
commit
9509522d16
@ -27,6 +27,10 @@ func beforeDeleteCallback(scope *Scope) {
|
||||
|
||||
// deleteCallback used to delete data from database or set deleted_at to current time (when using with soft delete)
|
||||
func deleteCallback(scope *Scope) {
|
||||
if scope.PrimaryKeyZero() {
|
||||
scope.db.AddError(ErrNonSpecificDelete)
|
||||
}
|
||||
|
||||
if !scope.HasError() {
|
||||
var extraOption string
|
||||
if str, ok := scope.Get("gorm:delete_option"); ok {
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNonSpecificDelete no primary key specified for delete, happens when you try to `Delete` a record without a primary key set
|
||||
ErrNonSpecificDelete = errors.New("no primary key specified for delete")
|
||||
// ErrRecordNotFound record not found error, happens when haven't find any matched data when looking up with a struct
|
||||
ErrRecordNotFound = errors.New("record not found")
|
||||
// ErrInvalidSQL invalid SQL error, happens when you passed invalid SQL
|
||||
|
Loading…
x
Reference in New Issue
Block a user