- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 38 for KSession (0.18 sec)
-
tests/transaction_test.go
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() user2 := *GetUser("transaction-2", Config{}) if err := tx2.Save(&user2).Error; err != nil { t.Fatalf("No error should raise, but got %v", err) }
Go - Registered: Sun Apr 21 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 21 09:35:09 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 846 bytes - Viewed (0) -
tests/update_many2many_test.go
t.Fatalf("errors happened when update: %v", err) } var user3 User DB.Preload("Languages").Preload("Friends").Find(&user3, "id = ?", user.ID) CheckUser(t, user2, user3) if err := DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&user).Error; err != nil { t.Fatalf("errors happened when update: %v", err) } var user4 User DB.Preload("Languages").Preload("Friends").Find(&user4, "id = ?", user.ID)
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 1.3K bytes - Viewed (0) -
tests/scanner_valuer_test.go
} } func TestGORMValuer(t *testing.T) { type UserWithPoint struct { Name string Point Point } dryRunDB := DB.Session(&gorm.Session{DryRun: true}) stmt := dryRunDB.Create(&UserWithPoint{ Name: "jinzhu", Point: Point{X: 100, Y: 100}, }).Statement if stmt.SQL.String() == "" || len(stmt.Vars) != 2 {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Wed Jun 07 07:02:07 GMT 2023 - 10.6K bytes - Viewed (0) -
tests/update_test.go
} dryDB := DB.Session(&gorm.Session{DryRun: true}) stmt := dryDB.Save(&user).Statement if !regexp.MustCompile(`.users.\..deleted_at. IS NULL`).MatchString(stmt.SQL.String()) { t.Fatalf("invalid updating SQL, got %v", stmt.SQL.String()) } dryDB = DB.Session(&gorm.Session{DryRun: true}) stmt = dryDB.Unscoped().Save(&user).Statement
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Dec 04 03:50:58 GMT 2023 - 30.3K bytes - Viewed (0) -
callbacks/associations.go
} for i := 0; i < elemLen; i++ { appendToJoins(objs[i], elems.Index(i)) } } if joins.Len() > 0 { db.AddError(db.Session(&gorm.Session{NewDB: true}).Clauses(clause.OnConflict{DoNothing: true}).Session(&gorm.Session{ SkipHooks: db.Statement.SkipHooks, DisableNestedTransaction: true, }).Create(joins.Interface()).Error) } } } } }
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Tue Apr 11 03:06:13 GMT 2023 - 14.3K bytes - Viewed (0) -
tests/scopes_test.go
} db := DB.Scopes(func(tx *gorm.DB) *gorm.DB { return tx.Table("custom_table") }).Session(&gorm.Session{}) db.AutoMigrate(&User{}) if db.Find(&User{}).Statement.Table != "custom_table" { t.Errorf("failed to call Scopes") } result := DB.Scopes(NameIn1And2, func(tx *gorm.DB) *gorm.DB { return tx.Session(&gorm.Session{}) }).Find(&users1) if result.RowsAffected != 2 {
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Fri Jan 12 08:42:21 GMT 2024 - 3.3K bytes - Viewed (0) -
migrator/migrator.go
} } return } func (m Migrator) GetQueryAndExecTx() (queryTx, execTx *gorm.DB) { queryTx = m.DB.Session(&gorm.Session{}) execTx = queryTx if m.DB.DryRun { queryTx.DryRun = false execTx = m.DB.Session(&gorm.Session{Logger: &printSQLLogger{Interface: m.DB.Logger}}) } return queryTx, execTx } // AutoMigrate auto migrate values
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Mon Mar 18 11:24:16 GMT 2024 - 28.5K bytes - Viewed (0) -
tests/distinct_test.go
t.Errorf("failed to query users count, got error: %v, count %v", err, count) } dryDB := DB.Session(&gorm.Session{DryRun: true}) r := dryDB.Distinct("u.id, u.*").Table("user_speaks as s").Joins("inner join users as u on u.id = s.user_id").Where("s.language_code ='US' or s.language_code ='ES'").Find(&User{})
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 2.5K bytes - Viewed (0) -
tests/hooks_test.go
} DB.Model(&product).Session(&gorm.Session{SkipHooks: true}).Updates(Product3{Code: "L1216"}) if product.Price != 320 || product.Code != "L1216" { t.Errorf("invalid data after update, got %+v", product) } var result2 Product3 DB.First(&result2, product.ID) AssertEqual(t, result2, product) product2 := Product3{Name: "Product", Price: 0} DB.Session(&gorm.Session{SkipHooks: true}).Create(&product2)
Go - Registered: Sun Apr 21 09:35:09 GMT 2024 - Last Modified: Sat Feb 18 01:20:29 GMT 2023 - 15.9K bytes - Viewed (0)