- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 30 for callback (0.17 sec)
-
callbacks.go
var callbacks []*callback removedMap := map[string]bool{} for _, callback := range p.callbacks { if callback.match == nil || callback.match(p.db) { callbacks = append(callbacks, callback) } if callback.remove { removedMap[callback.name] = true } } if len(removedMap) > 0 { callbacks = removeCallbacks(callbacks, removedMap) } p.callbacks = callbacks
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Tue Mar 26 03:33:36 GMT 2024 - 8.6K bytes - Viewed (1) -
schema/callbacks_test.go
return nil } func TestCallback(t *testing.T) { user, err := schema.Parse(&UserWithCallback{}, &sync.Map{}, schema.NamingStrategy{}) if err != nil { t.Fatalf("failed to parse user with callback, got error %v", err) } for _, str := range []string{"BeforeSave", "AfterCreate"} { if !reflect.Indirect(reflect.ValueOf(user)).FieldByName(str).Interface().(bool) { t.Errorf("%v should be true", str) } }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 939 bytes - Viewed (0) -
tests/callbacks_test.go
}, { callbacks: []callback{{h: c1}, {h: c2}, {h: c3}, {h: c4}, {h: c5, before: "c4"}}, results: []string{"c1", "c2", "c3", "c5", "c4"}, }, { callbacks: []callback{{h: c1}, {h: c2}, {h: c3}, {h: c4, after: "c5"}, {h: c5}}, results: []string{"c1", "c2", "c3", "c5", "c4"}, }, { callbacks: []callback{{h: c1}, {h: c2}, {h: c3}, {h: c4, after: "c5"}, {h: c5, before: "c4"}},
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Tue Mar 26 03:33:36 GMT 2024 - 7.2K bytes - Viewed (0) -
callbacks/callbacks.go
updateCallback.Match(enableTransaction).Register("gorm:commit_or_rollback_transaction", CommitOrRollbackTransaction) updateCallback.Clauses = config.UpdateClauses rowCallback := db.Callback().Row() rowCallback.Register("gorm:row", RowQuery) rowCallback.Clauses = config.QueryClauses rawCallback := db.Callback().Raw() rawCallback.Register("gorm:raw", RawExec) rawCallback.Clauses = config.QueryClauses
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Wed Oct 27 23:56:55 GMT 2021 - 3.3K bytes - Viewed (0) -
callbacks/visit_map_test.go
package callbacks import ( "reflect" "testing" ) func TestLoadOrStoreVisitMap(t *testing.T) { var vm visitMap var loaded bool type testM struct { Name string } t1 := testM{Name: "t1"} t2 := testM{Name: "t2"} t3 := testM{Name: "t3"} vm = make(visitMap) if loaded = loadOrStoreVisitMap(&vm, reflect.ValueOf(&t1)); loaded { t.Fatalf("loaded should be false") }
Go - Registered: Sun Feb 25 09:35:10 GMT 2024 - Last Modified: Thu Mar 17 15:53:31 GMT 2022 - 780 bytes - Viewed (0) -
callbacks/helper_test.go
package callbacks import ( "reflect" "testing" "gorm.io/gorm" "gorm.io/gorm/clause" ) func TestLoadOrStoreVisitMap(t *testing.T) { var vm visitMap var loaded bool type testM struct { Name string } t1 := testM{Name: "t1"} t2 := testM{Name: "t2"} t3 := testM{Name: "t3"} vm = make(visitMap) if loaded = loadOrStoreVisitMap(&vm, reflect.ValueOf(&t1)); loaded {
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Tue Mar 05 02:22:57 GMT 2024 - 3.4K bytes - Viewed (0) -
tests/preload_suits_test.go
}, } DB.Save(&lvl) var called int64 DB.Callback().Query().After("gorm:query").Register("TestPreloadManyToManyCallbacks", func(_ *gorm.DB) { atomic.AddInt64(&called, 1) }) DB.Preload("Level2s").First(&Level1{}, "id = ?", lvl.ID) if called != 3 { t.Errorf("Wanted callback to be called 3 times but got %d", called) }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Fri Mar 18 05:38:46 GMT 2022 - 30.3K bytes - Viewed (0) -
tests/hooks_test.go
DB.Save(&p2) p2.Code = "dont_update" if DB.Save(&p2).Error == nil { t.Fatalf("An error from before update callbacks happened when update with invalid value") } if DB.Where("code = ?", "update_callback").First(&Product{}).Error != nil { t.Fatalf("Record Should not be updated due to errors happened in before update callback") }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 15.9K bytes - Viewed (0) -
finisher_api.go
return tx } // Update updates column with value using callbacks. Reference: https://gorm.io/docs/update.html#Update-Changed-Fields func (db *DB) Update(column string, value interface{}) (tx *DB) { tx = db.getInstance() tx.Statement.Dest = map[string]interface{}{column: value} return tx.callbacks.Update().Execute(tx) }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Fri Jan 12 08:42:21 GMT 2024 - 22.7K bytes - Viewed (0) -
callbacks/transaction.go
package callbacks import ( "gorm.io/gorm" ) func BeginTransaction(db *gorm.DB) { if !db.Config.SkipDefaultTransaction && db.Error == nil { if tx := db.Begin(); tx.Error == nil { db.Statement.ConnPool = tx.Statement.ConnPool db.InstanceSet("gorm:started_transaction", true) } else if tx.Error == gorm.ErrInvalidTransaction { tx.Error = nil } else { db.Error = tx.Error } } }
Go - Registered: Sun May 05 09:35:13 GMT 2024 - Last Modified: Mon Nov 29 01:33:20 GMT 2021 - 675 bytes - Viewed (0)