Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for tons (0.12 sec)

  1. tests/associations_has_many_test.go

    		*GetUser("slice-hasmany-2", Config{Toys: 0, Tools: 2}),
    		*GetUser("slice-hasmany-3", Config{Toys: 4}),
    	}
    
    	DB.Create(&users)
    
    	// Count
    	AssertAssociationCount(t, users, "Toys", 6, "")
    	AssertAssociationCount(t, users, "Tools", 2, "")
    
    	// Find
    	var toys []Toy
    	if DB.Model(&users).Association("Toys").Find(&toys); len(toys) != 6 {
    		t.Errorf("toys count should be %v, but got %v", 6, len(toys))
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  2. 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}),
    		*GetUser("bulk_7", Config{Account: true, Pets: 1, Toys: 3, Company: true, Manager: true, Team: 4, Languages: 3, Friends: 1}),
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  3. schema/relationship_test.go

    		ID  int
    		Cat struct {
    			Name string
    			Toy  Toy   `gorm:"polymorphic:Owner;"`
    			Toys []Toy `gorm:"polymorphic:Owner;"`
    		} `gorm:"embedded;embeddedPrefix:cat_"`
    		Dog struct {
    			ID     int
    			Name   string
    			UserID int
    			Toy    Toy   `gorm:"polymorphic:Owner;"`
    			Toys   []Toy `gorm:"polymorphic:Owner;"`
    		}
    		Toys []Toy `gorm:"polymorphic:Owner;"`
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  4. tests/count_test.go

    		Preload("Toys", func(db *gorm.DB) *gorm.DB {
    			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 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  5. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  6. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  7. tests/associations_has_one_test.go

    	}
    
    	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
    	DB.Model(&pets).Association("Toy").Append(
    		&Toy{Name: "toy-slice-append-1"},
    		&Toy{Name: "toy-slice-append-2"},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K bytes
    - Viewed (0)
  8. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2K bytes
    - Viewed (0)
  9. schema/relationship.go

    				relationships.Relations = map[string]*Relationship{}
    			}
    			relationships.Relations[relation.Name] = relation
    		}
    	}
    }
    
    // User has many Toys, its `Polymorphic` is `Owner`, Pet has one Toy, its `Polymorphic` is `Owner`
    //
    //	type User struct {
    //	  Toys []Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Pet struct {
    //	  Toy Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Toy struct {
    //	  OwnerID   int
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  10. tests/query_test.go

    	}
    }
    
    func TestQueryWithAssociation(t *testing.T) {
    	user := *GetUser("query_with_association", Config{Account: true, Pets: 2, Toys: 1, Company: true, Manager: true, Team: 2, Languages: 1, Friends: 3})
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create user: %v", err)
    	}
    
    	user.CreatedAt = time.Time{}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
Back to top