Merge aa7b10be2907bb37995bf74fae0fd79a1236a3aa into 0a51f6cdc55d1650d9ed3b4c13026cfa9133b01e
This commit is contained in:
commit
d433743787
@ -41,7 +41,7 @@ func beforeUpdateCallback(scope *Scope) {
|
|||||||
scope.CallMethod("BeforeSave")
|
scope.CallMethod("BeforeSave")
|
||||||
}
|
}
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
scope.CallMethod("BeforeUpdate")
|
scope.CallMethod("GormBeforeUpdate")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ func updateCallback(scope *Scope) {
|
|||||||
func afterUpdateCallback(scope *Scope) {
|
func afterUpdateCallback(scope *Scope) {
|
||||||
if _, ok := scope.Get("gorm:update_column"); !ok {
|
if _, ok := scope.Get("gorm:update_column"); !ok {
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
scope.CallMethod("AfterUpdate")
|
scope.CallMethod("GormAfterUpdate")
|
||||||
}
|
}
|
||||||
if !scope.HasError() {
|
if !scope.HasError() {
|
||||||
scope.CallMethod("AfterSave")
|
scope.CallMethod("AfterSave")
|
||||||
|
@ -17,7 +17,7 @@ func (s *Product) BeforeCreate() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Product) BeforeUpdate() (err error) {
|
func (s *Product) GormBeforeUpdate() (err error) {
|
||||||
if s.Code == "dont_update" {
|
if s.Code == "dont_update" {
|
||||||
err = errors.New("can't update")
|
err = errors.New("can't update")
|
||||||
}
|
}
|
||||||
|
10
utils.go
10
utils.go
@ -266,11 +266,13 @@ func getValueFromFields(value reflect.Value, fieldNames []string) (results []int
|
|||||||
if indirectValue := reflect.Indirect(value); indirectValue.IsValid() {
|
if indirectValue := reflect.Indirect(value); indirectValue.IsValid() {
|
||||||
for _, fieldName := range fieldNames {
|
for _, fieldName := range fieldNames {
|
||||||
if fieldValue := indirectValue.FieldByName(fieldName); fieldValue.IsValid() {
|
if fieldValue := indirectValue.FieldByName(fieldName); fieldValue.IsValid() {
|
||||||
result := fieldValue.Interface()
|
if indirect(fieldValue).IsValid() {
|
||||||
if r, ok := result.(driver.Valuer); ok {
|
result := fieldValue.Interface()
|
||||||
result, _ = r.Value()
|
if r, ok := result.(driver.Valuer); ok {
|
||||||
|
result, _ = r.Value()
|
||||||
|
}
|
||||||
|
results = append(results, result)
|
||||||
}
|
}
|
||||||
results = append(results, result)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user