- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 17 for Mets (0.14 sec)
-
tests/helper_test.go
} } }) t.Run("Pets", func(t *testing.T) { if len(user.Pets) != len(expect.Pets) { t.Fatalf("pets should equal, expect: %v, got %v", len(expect.Pets), len(user.Pets)) } sort.Slice(user.Pets, func(i, j int) bool { return user.Pets[i].ID > user.Pets[j].ID }) sort.Slice(expect.Pets, func(i, j int) bool { return expect.Pets[i].ID > expect.Pets[j].ID })
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Tue Mar 19 03:50:28 GMT 2024 - 8K bytes - Viewed (0) -
tests/update_test.go
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Mon Dec 04 03:50:58 GMT 2023 - 30.3K bytes - Viewed (0) -
tests/associations_has_one_test.go
func TestPolymorphicHasOneAssociationForSlice(t *testing.T) { pets := []Pet{ {Name: "hasone-1", Toy: Toy{Name: "toy-has-one"}}, {Name: "hasone-2", Toy: Toy{}}, {Name: "hasone-3", Toy: Toy{Name: "toy-has-one"}}, } DB.Create(&pets) // Count AssertAssociationCount(t, pets, "Toy", 2, "") // Find var toys []Toy if DB.Model(&pets).Association("Toy").Find(&toys); len(toys) != 2 {
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 6.8K bytes - Viewed (0) -
utils/tests/models.go
package tests import ( "database/sql" "time" "gorm.io/gorm" ) // User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic) // He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table) // He speaks many languages (many to many) and has many friends (many to many - single-table) // His pet also has one Toy (has one - polymorphic)
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Fri Dec 15 08:36:08 GMT 2023 - 2.1K bytes - Viewed (0) -
tests/upsert_test.go
t.Errorf("user should be found and updated with assigned attrs") } DB.Where(&User{Name: "find or create embedded struct"}).Assign(User{Age: 44, Account: Account{Number: "1231231231"}, Pets: []*Pet{{Name: "first_or_create_pet1"}, {Name: "first_or_create_pet2"}}}).FirstOrCreate(&user8) if err := DB.Where("name = ?", "first_or_create_pet1").First(&Pet{}).Error; err != nil { t.Errorf("has many association should be saved")
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Mon Sep 05 07:39:19 GMT 2022 - 11.4K bytes - Viewed (0) -
tests/preload_test.go
} else { sort.Slice(users2[2].Pets, func(i, j int) bool { return users2[2].Pets[i].ID < users2[2].Pets[j].ID }) for _, pet := range users2[2].Pets[0:2] { if pet.Toy.Name != "" { t.Errorf("No toy should for user %v's pet %v but got %v", 3, pet.Name, pet.Toy.Name) } } CheckPet(t, *users2[2].Pets[2], *users[2].Pets[2]) } } func TestPreloadEmptyData(t *testing.T) {
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Apr 25 12:21:03 GMT 2024 - 14.9K bytes - Viewed (0) -
tests/delete_test.go
*GetUser("delete_slice_with_associations1", Config{Account: true, Pets: 4, Toys: 1, Company: true, Manager: true, Team: 1, Languages: 1, Friends: 4}), *GetUser("delete_slice_with_associations2", Config{Account: true, Pets: 3, Toys: 2, Company: true, Manager: true, Team: 2, Languages: 2, Friends: 3}), *GetUser("delete_slice_with_associations3", Config{Account: true, Pets: 2, Toys: 3, Company: true, Manager: true, Team: 3, Languages: 3, Friends: 2}),
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Tue Oct 10 07:03:34 GMT 2023 - 9.4K bytes - Viewed (0) -
schema/model_test.go
import ( "database/sql" "time" "gorm.io/gorm" "gorm.io/gorm/utils/tests" ) type User struct { *gorm.Model Name *string Age *uint Birthday *time.Time Account *tests.Account Pets []*tests.Pet Toys []*tests.Toy `gorm:"polymorphic:Owner"` CompanyID *int Company *tests.Company ManagerID *uint Manager *User Team []*User `gorm:"foreignkey:ManagerID"`
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Thu Jan 06 07:02:53 GMT 2022 - 1.1K bytes - Viewed (0) -
schema/schema_test.go
relations := []Relation{ { Name: "Account", Type: schema.HasOne, Schema: "User", FieldSchema: "Account", References: []Reference{{"ID", "User", "UserID", "Account", "", true}}, }, { Name: "Pets", Type: schema.HasMany, Schema: "User", FieldSchema: "Pet", References: []Reference{{"ID", "User", "UserID", "Pet", "", true}}, }, { Name: "Toys", Type: schema.HasMany, Schema: "User", FieldSchema: "Toy",
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Fri Dec 15 08:31:23 GMT 2023 - 12.9K bytes - Viewed (0) -
tests/table_test.go
if !regexp.MustCompile("SELECT \\* FROM \\(SELECT .name. FROM .users. WHERE .users.\\..deleted_at. IS NULL\\) as u, \\(SELECT .name. FROM .pets. WHERE .pets.\\..deleted_at. IS NULL\\) as p WHERE .u.\\..deleted_at. IS NULL").MatchString(r.Statement.SQL.String()) { t.Errorf("Table with escape character, got %v", r.Statement.SQL.String()) }
Go - Registered: Sun Apr 28 09:35:09 GMT 2024 - Last Modified: Sat Mar 09 09:31:28 GMT 2024 - 10.6K bytes - Viewed (0)