- Sort Score
- Result 10 results
- Languages All
Results 61 - 70 of 252 for Db (0.02 sec)
-
tests/migrate_test.go
t.Fatalf("Failed to get table %v when GetTables", t1) } } } for _, m := range allModels { if !DB.Migrator().HasTable(m) { t.Fatalf("Failed to create table for %#v", m) } } DB.Scopes(func(db *gorm.DB) *gorm.DB { return db.Table("ccc") }).Migrator().CreateTable(&Company{}) if !DB.Migrator().HasTable("ccc") { t.Errorf("failed to create table ccc") } for _, indexes := range [][2]string{
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Mar 18 11:24:16 UTC 2024 - 56.2K bytes - Viewed (0) -
tests/associations_many2many_test.go
DB.Create(&languages2_1) DB.Create(&languages2_2) DB.Create(&languages2_3) // Replace DB.Model(&users).Association("Languages").Replace(&languages2_1, &languages2_2, languages2_3) AssertAssociationCount(t, users, "Languages", 5, "After Replace") // Delete if err := DB.Model(&users).Association("Languages").Delete(&users[2].Languages); err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Jun 10 13:05:19 UTC 2023 - 13.2K bytes - Viewed (0) -
tests/update_test.go
DB.Create(&user) // Update a single field of the user and verify that the changed address is not stored. newAge := uint(100) user.Account.Number = "new_account_number" db := DB.Model(&user).UpdateColumns(User{Age: newAge}) if db.RowsAffected != 1 { t.Errorf("Expected RowsAffected=1 but instead RowsAffected=%v", db.RowsAffected) } // Verify that Age now=`newAge`.
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Dec 04 03:50:58 UTC 2023 - 30.3K bytes - Viewed (0) -
tests/group_by_test.go
Active: true, }, { Name: "groupby1", Age: 330, Birthday: Now(), Active: true, }} if err := DB.Create(&users).Error; err != nil { t.Errorf("errors happened when create: %v", err) } var name string var total int if err := DB.Model(&User{}).Select("name, sum(age)").Where("name = ?", "groupby").Group("name").Row().Scan(&name, &total); err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jan 06 07:02:53 UTC 2022 - 3.3K bytes - Viewed (0) -
tests/transaction_test.go
} } func TestDeeplyNestedTransactionWithBlockAndWrappedCallback(t *testing.T) { transaction := func(ctx context.Context, db *gorm.DB, callback func(ctx context.Context, db *gorm.DB) error) error { return db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { return callback(ctx, tx) }) } var ( user = *GetUser("transaction-nested", Config{}) user1 = *GetUser("transaction-nested-1", Config{})
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Sep 14 12:58:29 UTC 2024 - 12.9K bytes - Viewed (0) -
callbacks/callmethod.go
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++ {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Feb 18 01:20:29 UTC 2023 - 846 bytes - Viewed (0) -
tests/delete_test.go
func TestSoftDeleteReturning(t *testing.T) { if DB.Dialector.Name() != "sqlite" && DB.Dialector.Name() != "postgres" && DB.Dialector.Name() != "sqlserver" { return } users := []*User{ GetUser("delete-returning-1", Config{}), GetUser("delete-returning-2", Config{}), GetUser("delete-returning-3", Config{}), } DB.Create(&users) var results []User
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Tue Oct 10 07:03:34 UTC 2023 - 9.4K bytes - Viewed (0) -
tests/update_has_one_test.go
t.Fatalf("errors happened when update: %v", err) } var pet3 Pet DB.Preload("Toy").Find(&pet3, "id = ?", pet.ID) CheckPet(t, pet2, pet3) if err := DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&pet).Error; err != nil { t.Fatalf("errors happened when update: %v", err) } var pet4 Pet DB.Preload("Toy").Find(&pet4, "id = ?", pet.ID) CheckPet(t, pet4, pet) })
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jul 14 06:55:54 UTC 2022 - 3.6K bytes - Viewed (0) -
tests/customize_field_test.go
} DB.Migrator().DropTable(&CustomizeColumn{}) DB.AutoMigrate(&CustomizeColumn{}) expected := "foo" now := time.Now() cc := CustomizeColumn{ID: 666, Name: expected, Date: &now} if count := DB.Create(&cc).RowsAffected; count != 1 { t.Error("There should be one record be affected when create record") } var cc1 CustomizeColumn DB.First(&cc1, "mapped_name = ?", "foo")
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Sep 11 09:33:31 UTC 2020 - 6.9K bytes - Viewed (0) -
migrator.go
) // Migrator returns migrator func (db *DB) Migrator() Migrator { tx := db.getInstance() // apply scopes to migrator for len(tx.Statement.scopes) > 0 { tx = tx.executeScopes() } return tx.Dialector.Migrator(tx.Session(&Session{})) } // AutoMigrate run auto migration for given models func (db *DB) AutoMigrate(dst ...interface{}) error { return db.Migrator().AutoMigrate(dst...) }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Oct 30 09:15:49 UTC 2023 - 3.1K bytes - Viewed (0)