Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 27 for count (0.2 sec)

  1. tests/count_test.go

    		t.Errorf("count with join, got error: %v, count %v", err, count4)
    	}
    
    	var count5 int64
    	if err := DB.Table("users").Where("users.name = ?", user1.Name).Order("name").Count(&count5).Error; err != nil || count5 != 1 {
    		t.Errorf("count with join, got error: %v, count %v", err, count)
    	}
    
    	var count6 int64
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 6.9K bytes
    - Viewed (0)
  2. tests/associations_has_one_test.go

    		*GetUser("slice-hasone-3", Config{Account: true}),
    	}
    
    	DB.Create(&users)
    
    	// Count
    	AssertAssociationCount(t, users, "Account", 2, "")
    
    	// Find
    	var accounts []Account
    	if DB.Model(&users).Association("Account").Find(&accounts); len(accounts) != 2 {
    		t.Errorf("accounts count should be %v, but got %v", 3, len(accounts))
    	}
    
    	// Append
    	DB.Model(&users).Association("Account").Append(
    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)
  3. tests/distinct_test.go

    	}
    
    	var count int64
    	if err := DB.Model(&User{}).Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 5 {
    		t.Errorf("failed to query users count, got error: %v, count: %v", err, count)
    	}
    
    	if err := DB.Model(&User{}).Distinct("name").Where("name like ?", "distinct%").Count(&count).Error; err != nil || count != 3 {
    		t.Errorf("failed to query users count, got error: %v, count %v", err, count)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2.5K bytes
    - Viewed (0)
  4. migrator/migrator.go

    func (m Migrator) HasTable(value interface{}) bool {
    	var count int64
    
    	m.RunWithValue(value, func(stmt *gorm.Statement) error {
    		currentDatabase := m.DB.Migrator().CurrentDatabase()
    		return m.DB.Raw("SELECT count(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ? AND table_type = ?", currentDatabase, stmt.Table, "BASE TABLE").Row().Scan(&count)
    	})
    
    	return count > 0
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  5. tests/delete_test.go

    		if count := DB.Unscoped().Model(&user).Association(key).Count(); count != value {
    			t.Errorf("user's %v expects: %v, got %v", key, value, count)
    		}
    	}
    
    	for key, value := range map[string]int64{"Account": 0, "Pets": 0, "Toys": 0, "Company": 1, "Manager": 1, "Team": 0, "Languages": 0, "Friends": 0} {
    		if count := DB.Model(&user).Association(key).Count(); count != value {
    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)
  6. tests/named_polymorphic_test.go

    	}
    
    	// clear to omit Toy.ID in count
    	hamster2.PreferredToy = Toy{}
    	hamster2.OtherToy = Toy{}
    
    	if DB.Model(&hamster2).Association("PreferredToy").Count() != 1 {
    		t.Errorf("Hamster's preferred toy count should be 1")
    	}
    
    	if DB.Model(&hamster2).Association("OtherToy").Count() != 1 {
    		t.Errorf("Hamster's other toy count should be 1")
    	}
    
    	// Query
    	hamsterToy := Toy{}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Jul 08 09:59:40 GMT 2020
    - 4.2K bytes
    - Viewed (0)
  7. tests/joins_table_test.go

    		t.Fatalf("failed to delete person, got error: %v", err)
    	}
    
    	if count := DB.Unscoped().Model(&person2).Association("Addresses").Count(); count != 2 {
    		t.Errorf("person's addresses expects 2, got %v", count)
    	}
    
    	if count := DB.Model(&person2).Association("Addresses").Count(); count != 0 {
    		t.Errorf("person's addresses expects 2, got %v", count)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Sep 10 13:46:18 GMT 2020
    - 3.5K bytes
    - Viewed (0)
  8. tests/multi_primary_keys_test.go

    	if !compareTags(blog.Tags, []string{"tag1", "tag2", "tag3"}) {
    		t.Fatalf("Blog should has three tags after Append")
    	}
    
    	if count := DB.Model(&blog).Association("Tags").Count(); count != 3 {
    		t.Fatalf("Blog should has 3 tags after Append, got %v", count)
    	}
    
    	var tags []Tag
    	DB.Model(&blog).Association("Tags").Find(&tags)
    	if !compareTags(tags, []string{"tag1", "tag2", "tag3"}) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 12.8K bytes
    - Viewed (0)
  9. schema/schema_helper_test.go

    			if len(relations.Relations) != len(rs.Relations) {
    				t.Errorf("schema relations count don't match, expects %d, got %d", len(rs.Relations), len(relations.Relations))
    			}
    			if len(relations.EmbeddedRelations) != len(rs.EmbeddedRelations) {
    				t.Errorf("schema embedded relations count don't match, expects %d, got %d", len(rs.EmbeddedRelations), len(relations.EmbeddedRelations))
    			}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  10. tests/associations_belongs_to_test.go

    	var companies []Company
    	if DB.Model(&users).Association("Company").Find(&companies); len(companies) != 3 {
    		t.Errorf("companies count should be %v, but got %v", 3, len(companies))
    	}
    
    	var managers []User
    	if DB.Model(&users).Association("Manager").Find(&managers); len(managers) != 2 {
    		t.Errorf("managers count should be %v, but got %v", 2, len(managers))
    	}
    
    	// Append
    	DB.Model(&users).Association("Company").Append(
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
Back to top