Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 18 for Account (0.25 sec)

  1. tests/update_test.go

    		t.Errorf("should update two records, but got %v", rowsAffected)
    	}
    
    	var results []User
    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)
  2. tests/helper_test.go

    		"ManagerID", "Active")
    
    	t.Run("Account", func(t *testing.T) {
    		AssertObjEqual(t, user.Account, expect.Account, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "UserID", "Number")
    
    		if user.Account.Number != "" {
    			if !user.Account.UserID.Valid {
    				t.Errorf("Account's foreign key should be saved")
    			} else {
    				var account Account
    				db(unscoped).First(&account, "user_id = ?", user.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)
  3. tests/create_test.go

    	user.Birthday = nil
    	user.Account = Account{}
    	user.Toys = nil
    	user.Manager = nil
    
    	CheckUser(t, result, user)
    
    	user2 := *GetUser("omit_create", Config{Account: true, Pets: 3, Toys: 3, Company: true, Manager: true, Team: 3, Languages: 3, Friends: 4})
    	DB.Omit(clause.Associations).Create(&user2)
    
    	var result2 User
    	DB.Preload(clause.Associations).First(&result2, user2.ID)
    
    	user2.Account = Account{}
    	user2.Toys = nil
    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)
  4. utils/tests/models.go

    type User struct {
    	gorm.Model
    	Name      string
    	Age       uint
    	Birthday  *time.Time
    	Account   Account
    	Pets      []*Pet
    	NamedPet  *Pet
    	Toys      []Toy   `gorm:"polymorphic:Owner"`
    	Tools     []Tools `gorm:"polymorphicType:Type;polymorphicId:CustomID"`
    	CompanyID *int
    	Company   Company
    	ManagerID *uint
    	Manager   *User
    	Team      []User     `gorm:"foreignkey:ManagerID"`
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  5. tests/preload_test.go

    	}
    
    	var users2 []User
    	DB.Preload("Account", clause.Eq{Column: "number", Value: users[0].Account.Number}).Find(&users2, "id IN ?", userIDs)
    	sort.Slice(users2, func(i, j int) bool {
    		return users2[i].ID < users2[j].ID
    	})
    
    	for idx, user := range users2[1:2] {
    		if user.Account.Number != "" {
    			t.Errorf("No account should found for user %v but got %v", idx+2, user.Account.Number)
    		}
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 14.9K bytes
    - Viewed (0)
  6. tests/associations_has_many_test.go

    	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 {
    		t.Fatalf("should only find no pet with invalid conditions, but got %v", count)
    	}
    
    	// Count
    	AssertAssociationCount(t, user, "Pets", 2, "")
    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)
  7. chainable_api.go

    	}
    	return
    }
    
    // Joins specify Joins conditions
    //
    //	db.Joins("Account").Find(&user)
    //	db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "******@****.***").Find(&user)
    //	db.Joins("Account", DB.Select("id").Where("user_id = users.id AND name = ?", "someName").Model(&Account{}))
    func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  8. schema/relationship_test.go

    	})
    }
    
    func TestVariableRelation(t *testing.T) {
    	var result struct {
    		User
    	}
    
    	checkStructRelation(t, &result, Relation{
    		Name: "Account", Type: schema.HasOne, Schema: "", FieldSchema: "Account",
    		References: []Reference{
    			{"ID", "", "UserID", "Account", "", true},
    		},
    	})
    
    	checkStructRelation(t, &result, Relation{
    		Name: "Company", Type: schema.BelongsTo, Schema: "", FieldSchema: "Company",
    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)
  9. schema/schema_test.go

    			f.Creatable = true
    			f.Updatable = true
    			f.Readable = true
    		})
    	}
    
    	// check relations
    	relations := []Relation{
    		{
    			Name: "Account", Type: schema.HasOne, Schema: "User", FieldSchema: "Account",
    			References: []Reference{{"ID", "User", "UserID", "Account", "", true}},
    		},
    		{
    			Name: "Pets", Type: schema.HasMany, Schema: "User", FieldSchema: "Pet",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 12.9K bytes
    - Viewed (0)
  10. tests/migrate_test.go

    	if err := DB.Migrator().CreateView("users_pets", gorm.ViewOption{Query: query}); err != nil {
    		t.Fatalf("Failed to crate view, got %v", err)
    	}
    
    	var count int64
    	if err := DB.Table("users_pets").Count(&count).Error; err != nil {
    		t.Fatalf("should found created view")
    	}
    
    	if err := DB.Migrator().DropView("users_pets"); err != nil {
    		t.Fatalf("Failed to drop view, got %v", err)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top