Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 835 for Pets (0.15 sec)

  1. 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 21 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  2. 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 21 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 13.4K bytes
    - Viewed (0)
  3. tests/update_has_many_test.go

    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	user.Pets = []*Pet{{Name: "pet1"}, {Name: "pet2"}}
    	if err := DB.Save(&user).Error; err != nil {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user2 User
    	DB.Preload("Pets").Find(&user2, "id = ?", user.ID)
    	CheckUser(t, user2, user)
    
    	for _, pet := range user.Pets {
    		pet.Name += "new"
    	}
    
    	if err := DB.Save(&user).Error; err != nil {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2K bytes
    - Viewed (0)
  4. tests/associations_has_many_test.go

    	if len(pets) != 1 {
    		t.Fatalf("should only find one pets, but got %v", len(pets))
    	}
    
    	CheckPet(t, pets[0], *user.Pets[0])
    
    	if count := DB.Model(&user).Where("name = ?", user.Pets[1].Name).Association("Pets").Count(); count != 1 {
    		t.Fatalf("should only find one pets, but got %v", count)
    	}
    
    	if count := DB.Model(&user).Where("name = ?", "not found").Association("Pets").Count(); count != 0 {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  5. tests/update_test.go

    	result.Pets = append(user.Pets, result.Pets...)
    	result.Team = append(user.Team, result.Team...)
    	result.Friends = append(user.Friends, result.Friends...)
    
    	sort.Slice(result.Pets, func(i, j int) bool {
    		return result.Pets[i].ID < result.Pets[j].ID
    	})
    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)
  6. tests/joins_test.go

    	DB.Joins("inner join pets on pets.user_id = users.id AND pets.name = @Name", user.Pets[0]).Where("users.name = ?", user.Name).First(&users6)
    	if len(users6) != 1 {
    		t.Errorf("should find one users using left join with conditions, but got %v", len(users6))
    	}
    
    	dryDB := DB.Session(&gorm.Session{DryRun: true})
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  7. 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 21 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
  8. tests/create_test.go

    		*GetUser("bulk_5", Config{Account: false, Pets: 0, Toys: 3, Company: true, Manager: false, Team: 1, Languages: 3, Friends: 1}),
    		*GetUser("bulk_6", Config{Account: true, Pets: 4, Toys: 3, Company: false, Manager: true, Team: 1, Languages: 3, Friends: 0}),
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  9. 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 21 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  10. tests/associations_test.go

    			children, parent.Children)
    	}
    }
    
    func TestAssociationError(t *testing.T) {
    	user := *GetUser("TestAssociationError", Config{Pets: 2, Company: true, Account: true, Languages: 2})
    	DB.Create(&user)
    
    	var user1 User
    	DB.Preload("Company").Preload("Pets").Preload("Account").Preload("Languages").First(&user1)
    
    	var emptyUser User
    	var err error
    	// belongs to
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Feb 08 08:29:09 GMT 2023
    - 10.9K bytes
    - Viewed (0)
Back to top