Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 85 for toys (0.17 sec)

  1. tests/update_has_many_test.go

    			t.Fatalf("errors happened when create: %v", err)
    		}
    
    		user.Toys = []Toy{{Name: "toy1"}, {Name: "toy2"}}
    		if err := DB.Save(&user).Error; err != nil {
    			t.Fatalf("errors happened when update: %v", err)
    		}
    
    		var user2 User
    		DB.Preload("Toys").Find(&user2, "id = ?", user.ID)
    		CheckUser(t, user2, user)
    
    		for idx := range user.Toys {
    			user.Toys[idx].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)
  2. tests/associations_has_many_test.go

    	if err := DB.Model(&user2).Association("Toys").Append(&toys); err != nil {
    		t.Fatalf("Error happened when append toy, got %v", err)
    	}
    
    	for _, toy := range toys {
    		toy := toy
    		if toy.ID == 0 {
    			t.Fatalf("Toy's ID should be created")
    		}
    
    		user.Toys = append(user.Toys, toy)
    	}
    
    	CheckUser(t, user2, user)
    
    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)
  3. tests/helper_test.go

    			}
    		}
    	})
    
    	t.Run("Toys", func(t *testing.T) {
    		if len(user.Toys) != len(expect.Toys) {
    			t.Fatalf("toys should equal, expect: %v, got %v", len(expect.Toys), len(user.Toys))
    		}
    
    		sort.Slice(user.Toys, func(i, j int) bool {
    			return user.Toys[i].ID > user.Toys[j].ID
    		})
    
    		sort.Slice(expect.Toys, func(i, j int) bool {
    			return expect.Toys[i].ID > expect.Toys[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)
  4. tests/create_test.go

    	t.Run("SliceOfPtr", func(t *testing.T) {
    		pets := []*Pet{{
    			Name: "PolymorphicHasOne-Slice-1",
    			Toy:  Toy{Name: "Toy-PolymorphicHasOne-Slice-1"},
    		}, {
    			Name: "PolymorphicHasOne-Slice-2",
    			Toy:  Toy{Name: "Toy-PolymorphicHasOne-Slice-2"},
    		}, {
    			Name: "PolymorphicHasOne-Slice-3",
    			Toy:  Toy{Name: "Toy-PolymorphicHasOne-Slice-3"},
    		}}
    
    		if err := DB.Create(&pets).Error; err != nil {
    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)
  5. tests/update_test.go

    	result.Languages = append(user.Languages, result.Languages...)
    	result.Toys = append(user.Toys, result.Toys...)
    
    	sort.Slice(result.Languages, func(i, j int) bool {
    		return strings.Compare(result.Languages[i].Code, result.Languages[j].Code) > 0
    	})
    
    	sort.Slice(result.Toys, func(i, j int) bool {
    		return result.Toys[i].ID < result.Toys[j].ID
    	})
    
    	sort.Slice(result2.Languages, func(i, j int) bool {
    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/associations_has_one_test.go

    		{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 {
    		t.Errorf("toys count should be %v, but got %v", 3, len(toys))
    	}
    
    	// Append
    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)
  7. tests/named_polymorphic_test.go

    		t.Errorf("Hamster's preferred toy failed to preload")
    	}
    
    	if hamster2.OtherToy.ID != hamster.OtherToy.ID || hamster2.OtherToy.Name != hamster.OtherToy.Name {
    		t.Errorf("Hamster's other toy failed to preload")
    	}
    
    	// clear to omit Toy.ID in count
    	hamster2.PreferredToy = Toy{}
    	hamster2.OtherToy = Toy{}
    
    	if DB.Model(&hamster2).Association("PreferredToy").Count() != 1 {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Wed Jul 08 09:59:40 GMT 2020
    - 4.2K bytes
    - Viewed (0)
  8. 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)
  9. utils/tests/models.go

    	Active    bool
    }
    
    type Account struct {
    	gorm.Model
    	UserID sql.NullInt64
    	Number string
    }
    
    type Pet struct {
    	gorm.Model
    	UserID *uint
    	Name   string
    	Toy    Toy `gorm:"polymorphic:Owner;"`
    }
    
    type Toy struct {
    	gorm.Model
    	Name      string
    	OwnerID   string
    	OwnerType string
    }
    
    type Tools struct {
    	gorm.Model
    	Name     string
    	CustomID string
    	Type     string
    }
    
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  10. schema/relationship_test.go

    			UserID int
    			Toy    Toy   `gorm:"polymorphic:Owner;"`
    			Toys   []Toy `gorm:"polymorphic:Owner;"`
    		}
    		Toys []Toy `gorm:"polymorphic:Owner;"`
    	}
    
    	s, err := schema.Parse(&User{}, &sync.Map{}, schema.NamingStrategy{})
    	if err != nil {
    		t.Fatalf("Failed to parse schema, got error %v", err)
    	}
    
    	checkEmbeddedRelations(t, s.Relationships.EmbeddedRelations, map[string]EmbeddedRelations{
    		"Cat": {
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
Back to top