- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 30 for fallback (0.18 sec)
-
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 Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 939 bytes - Viewed (0) -
tests/transaction_test.go
} if sqlTx, ok := tx.Statement.ConnPool.(gorm.TxCommitter); !ok || sqlTx == nil { t.Fatalf("Should return the underlying sql.Tx") } tx.Rollback() if err := DB.First(&User{}, "name = ?", "transaction").Error; err == nil { t.Fatalf("Should not find record after rollback, but got %v", err) } txDB := DB.Where("fake_name = ?", "fake_name") tx2 := txDB.Session(&gorm.Session{NewDB: true}).Begin()
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Sat Jun 10 13:05:19 GMT 2023 - 10.9K bytes - Viewed (0) -
callbacks/callmethod.go
package callbacks import ( "reflect" "gorm.io/gorm" ) func callMethod(db *gorm.DB, fc func(value interface{}, tx *gorm.DB) bool) { tx := db.Session(&gorm.Session{NewDB: true}) if called := fc(db.Statement.ReflectValue.Interface(), tx); !called { switch db.Statement.ReflectValue.Kind() { case reflect.Slice, reflect.Array: db.Statement.CurDestIndex = 0 for i := 0; i < db.Statement.ReflectValue.Len(); i++ {
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 846 bytes - Viewed (0) -
prepare_stmt.go
if tx.Tx != nil && !reflect.ValueOf(tx.Tx).IsNil() { return tx.Tx.Commit() } return ErrInvalidTransaction } func (tx *PreparedStmtTX) Rollback() error { if tx.Tx != nil && !reflect.ValueOf(tx.Tx).IsNil() { return tx.Tx.Rollback() } return ErrInvalidTransaction } func (tx *PreparedStmtTX) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error) {
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Mar 28 08:47:39 GMT 2024 - 6.4K 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 Apr 28 09:35:09 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 Apr 28 09:35:09 GMT 2024 - Last Modified: Wed Oct 27 23:56:55 GMT 2021 - 3.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 Apr 28 09:35:09 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 15.9K bytes - Viewed (0) -
callbacks/interfaces.go
package callbacks import "gorm.io/gorm" type BeforeCreateInterface interface { BeforeCreate(*gorm.DB) error } type AfterCreateInterface interface { AfterCreate(*gorm.DB) error } type BeforeUpdateInterface interface { BeforeUpdate(*gorm.DB) error } type AfterUpdateInterface interface { AfterUpdate(*gorm.DB) error } type BeforeSaveInterface interface { BeforeSave(*gorm.DB) error }
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Aug 27 07:03:57 GMT 2020 - 667 bytes - Viewed (0) -
soft_delete.go
} } } SoftDeleteQueryClause(sd).ModifyStatement(stmt) stmt.AddClauseIfNotExists(clause.Update{}) stmt.Build(stmt.DB.Callback().Update().Clauses...) }
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Wed Feb 01 06:40:55 GMT 2023 - 4.5K bytes - Viewed (0) -
callbacks/create_test.go
package callbacks import ( "reflect" "sync" "testing" "time" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" ) var schemaCache = &sync.Map{} func TestConvertToCreateValues_DestType_Slice(t *testing.T) { type user struct { ID int `gorm:"primaryKey"` Name string Email string `gorm:"default:(-)"` Age int `gorm:"default:(-)"` }
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Mon Mar 18 05:48:42 GMT 2024 - 1.4K bytes - Viewed (0)