Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 38 for Toy (0.01 sec)

  1. tests/helper_test.go

    	AssertObjEqual(t, pet, expect, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Name")
    
    	AssertObjEqual(t, pet.Toy, expect.Toy, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "OwnerID", "OwnerType")
    
    	if expect.Toy.Name != "" && expect.Toy.OwnerType != "pets" {
    		t.Errorf("toys's OwnerType, expect: %v, got %v", "pets", expect.Toy.OwnerType)
    	}
    }
    
    func CheckUserUnscoped(t *testing.T, user User, expect User) {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Tue Mar 19 03:50:28 UTC 2024
    - 8K bytes
    - Viewed (0)
  2. schema/relationship_test.go

    				"Toy": {
    					Name:        "Toy",
    					Type:        schema.HasOne,
    					Schema:      "User",
    					FieldSchema: "Toy",
    					Polymorphic: Polymorphic{ID: "OwnerID", Type: "OwnerType", Value: "users"},
    					References: []Reference{
    						{ForeignKey: "OwnerType", ForeignSchema: "Toy", PrimaryValue: "users"},
    						{ForeignKey: "OwnerType", ForeignSchema: "Toy", PrimaryValue: "users"},
    					},
    				},
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Apr 15 03:20:20 UTC 2024
    - 25.5K bytes
    - Viewed (0)
  3. tests/associations_has_one_test.go

    	// Append
    	toy := Toy{Name: "toy-has-one-append"}
    
    	if err := DB.Model(&pet2).Association("Toy").Append(&toy); err != nil {
    		t.Fatalf("Error happened when append toy, got %v", err)
    	}
    
    	if toy.ID == 0 {
    		t.Fatalf("Toy's ID should be created")
    	}
    
    	pet.Toy = toy
    	CheckPet(t, pet2, pet)
    
    	AssertAssociationCount(t, pet, "Toy", 1, "AfterAppend")
    
    	// Replace
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 7.1K bytes
    - Viewed (0)
  4. tests/create_test.go

    		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 {
    			t.Fatalf("errors happened when create: %v", err)
    		}
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Tue Mar 19 03:50:28 UTC 2024
    - 26.4K bytes
    - Viewed (0)
  5. tests/preload_test.go

    	user := *GetUser("nested_preload", Config{Pets: 1})
    	pet := user.Pets[0]
    	pet.Toy = Toy{Name: "toy_nested_preload_" + strconv.Itoa(1)}
    	pet.Toy = Toy{Name: "toy_nested_preload_" + strconv.Itoa(2)}
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	var user2 User
    	DB.Preload("Pets.Toy").Find(&user2, "id = ?", user.ID)
    	CheckUser(t, user2, user)
    
    	DB.Delete(&pet)
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:00:47 UTC 2024
    - 15.9K bytes
    - Viewed (0)
  6. 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 {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jul 08 09:59:40 UTC 2020
    - 4.2K bytes
    - Viewed (0)
  7. tests/update_has_one_test.go

    			t.Fatalf("errors happened when create: %v", err)
    		}
    
    		pet.Toy = Toy{Name: "Update-HasOneAssociation-Polymorphic"}
    
    		if err := DB.Save(&pet).Error; err != nil {
    			t.Fatalf("errors happened when create: %v", err)
    		}
    
    		var pet2 Pet
    		DB.Preload("Toy").Find(&pet2, "id = ?", pet.ID)
    		CheckPet(t, pet2, pet)
    
    		pet.Toy.Name += "new"
    		if err := DB.Save(&pet).Error; err != nil {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Jul 14 06:55:54 UTC 2022
    - 3.6K bytes
    - Viewed (0)
  8. tests/associations_has_many_test.go

    	DB.Model(&users).Association("Toys").Append(
    		&Toy{Name: "toy-slice-append-1"},
    		[]Toy{{Name: "toy-slice-append-2-1"}, {Name: "toy-slice-append-2-2"}},
    		&Toy{Name: "toy-slice-append-3"},
    	)
    
    	AssertAssociationCount(t, users, "Toys", 10, "After Append")
    
    	// Replace -> same as append
    	DB.Model(&users).Association("Toys").Replace(
    		[]*Toy{{Name: "toy-slice-replace-1-1"}, {Name: "toy-slice-replace-1-2"}},
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 16K bytes
    - Viewed (0)
  9. tests/joins_test.go

    					Name: "nested-joins-manager-company-1",
    				},
    				NamedPet: &Pet{
    					Name: "nested-joins-manager-namepet-1",
    					Toy: Toy{
    						Name: "nested-joins-manager-namepet-toy-1",
    					},
    				},
    			},
    			NamedPet: &Pet{Name: "nested-joins-namepet-1", Toy: Toy{Name: "nested-joins-namepet-toy-1"}},
    		},
    		{
    			Name:     "nested-joins-2",
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Jun 17 03:58:13 UTC 2024
    - 15K bytes
    - Viewed (0)
  10. 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
    }
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Dec 15 08:36:08 UTC 2023
    - 2.1K bytes
    - Viewed (0)
Back to top