- Sort Score
- Result 10 results
- Languages All
Results 21 - 30 of 252 for DB (0.03 sec)
-
tests/joins_table_test.go
} DB.Model(&person).Association("Addresses").Clear() if DB.Model(&person).Association("Addresses").Count() != 0 { t.Fatalf("Should deleted all addresses") } if DB.Unscoped().Model(&person).Association("Addresses").Count() != 2 { t.Fatalf("Should found soft deleted addresses with unscoped") } DB.Unscoped().Model(&person).Association("Addresses").Clear()
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Sep 10 13:46:18 UTC 2020 - 3.5K bytes - Viewed (0) -
tests/count_test.go
return db.Table("toys").Select("name") }).Count(&count12).Error; err == nil { t.Errorf("error should raise when using preload without schema") } var count13 int64 if err := DB.Model(User{}). Where("name in ?", []string{user1.Name, user2.Name, user3.Name}). Preload("Toys", func(db *gorm.DB) *gorm.DB { return db.Table("toys").Select("name") }).Count(&count13).Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Oct 30 09:15:49 UTC 2023 - 6.9K bytes - Viewed (0) -
tests/hooks_test.go
DB.Migrator().DropTable(&Product{}) DB.AutoMigrate(&Product{}) p := Product{Code: "Invalid", Price: 100} if DB.Save(&p).Error == nil { t.Fatalf("An error from before create callbacks happened when create with invalid value") } if DB.Where("code = ?", "Invalid").First(&Product{}).Error == nil { t.Fatalf("Should not save record that have errors") }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 17 03:59:06 UTC 2024 - 16.7K bytes - Viewed (0) -
tests/embedded_struct_test.go
*Author `gorm:"EmbeddedPrefix:user_"` // Embedded struct } DB.Migrator().DropTable(&HNPost{}) if err := DB.Migrator().AutoMigrate(&HNPost{}); err != nil { t.Fatalf("failed to auto migrate, got error: %v", err) } DB.Create(&HNPost{BasePost: &BasePost{Title: "embedded_pointer_type"}}) var hnPost HNPost if err := DB.First(&hnPost, "title = ?", "embedded_pointer_type").Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed May 08 04:07:58 UTC 2024 - 7.3K bytes - Viewed (0) -
tests/query_test.go
ID ID Name string } DB.Migrator().DropTable(&CustomizedTypePrimaryKey{}) if err := DB.AutoMigrate(&CustomizedTypePrimaryKey{}); err != nil { t.Fatalf("failed to migrate, got error %v", err) } p1 := CustomizedTypePrimaryKey{Name: "p1"} p2 := CustomizedTypePrimaryKey{Name: "p2"} p3 := CustomizedTypePrimaryKey{Name: "p3"} DB.Create(&p1) DB.Create(&p2) DB.Create(&p3)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 24 09:42:59 UTC 2024 - 50.4K bytes - Viewed (0) -
tests/sql_builder_test.go
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Jan 12 08:42:21 UTC 2024 - 16.7K bytes - Viewed (0) -
tests/named_polymorphic_test.go
} DB.Model(&hamster).Association("PreferredToy").Clear() if DB.Model(&hamster2).Association("PreferredToy").Count() != 0 { t.Errorf("Hamster's preferred toy should be cleared with Clear") } if DB.Model(&hamster2).Association("OtherToy").Count() != 1 { t.Errorf("Hamster's other toy should be still available") } DB.Model(&hamster).Association("OtherToy").Clear()
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jul 08 09:59:40 UTC 2020 - 4.2K bytes - Viewed (0) -
tests/soft_delete_test.go
DeletedAt gorm.DeletedAt `gorm:"zeroValue:'1970-01-01 00:00:01'"` } DB.Migrator().DropTable(&SoftDeleteBook{}) if err := DB.AutoMigrate(&SoftDeleteBook{}); err != nil { t.Fatalf("failed to auto migrate soft delete table") } book := SoftDeleteBook{Name: "jinzhu", Pages: 10} DB.Save(&book) var count int64 if DB.Model(&SoftDeleteBook{}).Where("name = ?", book.Name).Count(&count).Error != nil || count != 1 {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Feb 01 06:40:55 UTC 2023 - 5.7K bytes - Viewed (0) -
migrator/migrator.go
type GormDataTypeInterface interface { GormDBDataType(*gorm.DB, *schema.Field) string } // RunWithValue run migration with statement value func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error { stmt := &gorm.Statement{DB: m.DB} if m.DB.Statement != nil { stmt.Table = m.DB.Statement.Table stmt.TableExpr = m.DB.Statement.TableExpr } if table, ok := value.(string); ok {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Fri Apr 26 07:15:49 UTC 2024 - 29K bytes - Viewed (0) -
tests/update_belongs_to_test.go
if err := DB.Create(&user).Error; err != nil { t.Fatalf("errors happened when create: %v", err) } user.Company = Company{Name: "company-belongs-to-association"} user.Manager = &User{Name: "manager-belongs-to-association"} if err := DB.Save(&user).Error; err != nil { t.Fatalf("errors happened when update: %v", err) } var user2 User
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jul 14 06:55:54 UTC 2022 - 1.6K bytes - Viewed (0)