Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 19 for Account (0.21 sec)

  1. tests/update_has_one_test.go

    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	user.Account = Account{Number: "account-has-one-association"}
    
    	if err := DB.Save(&user).Error; err != nil {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user2 User
    	DB.Preload("Account").Find(&user2, "id = ?", user.ID)
    	CheckUser(t, user2, user)
    
    	user.Account.Number += "new"
    	if err := DB.Save(&user).Error; err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jul 14 06:55:54 GMT 2022
    - 3.6K bytes
    - Viewed (0)
  2. tests/associations_has_one_test.go

    	account := Account{Number: "account-has-one-append"}
    
    	if err := DB.Model(&user2).Association("Account").Append(&account); err != nil {
    		t.Fatalf("Error happened when append account, got %v", err)
    	}
    
    	if account.ID == 0 {
    		t.Fatalf("Account's ID should be created")
    	}
    
    	user.Account = account
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user, "Account", 1, "AfterAppend")
    
    	// Replace
    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)
  3. 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)
  4. tests/count_test.go

    	if count != int64(len(users)) {
    		t.Errorf("Count() method should get correct value, expect: %v, got %v", count, len(users))
    	}
    
    	if err := DB.Model(&User{}).Where("name = ?", user1.Name).Or("name = ?", user3.Name).Count(&count).Find(&users).Error; err != nil {
    		t.Errorf(fmt.Sprintf("Count should work, but got err %v", err))
    	}
    
    	if count != int64(len(users)) {
    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/soft_delete_test.go

    		t.Errorf("Should find soft deleted record with Unscoped, but got err %s", err)
    	}
    
    	count = 0
    	if DB.Unscoped().Model(&User{}).Where("name = ?", user.Name).Count(&count).Error != nil || count != 1 {
    		t.Errorf("Count soft deleted record, expects: %v, count: %v", 1, count)
    	}
    
    	age = 0
    	if DB.Unscoped().Model(&User{}).Select("age").Where("name = ?", user.Name).Scan(&age).Error != nil || age != user.Age {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 5.7K bytes
    - Viewed (0)
  6. tests/delete_test.go

    	}
    
    	for key, value := range map[string]int64{"Account": 1, "Pets": 2, "Toys": 4, "Company": 1, "Manager": 1, "Team": 1, "Languages": 0, "Friends": 0} {
    		if count := DB.Unscoped().Model(&user).Association(key).Count(); count != value {
    			t.Errorf("user's %v expects: %v, got %v", key, value, count)
    		}
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  7. 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)
  8. schema/model_test.go

    package schema_test
    
    import (
    	"database/sql"
    	"time"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/utils/tests"
    )
    
    type User struct {
    	*gorm.Model
    	Name      *string
    	Age       *uint
    	Birthday  *time.Time
    	Account   *tests.Account
    	Pets      []*tests.Pet
    	Toys      []*tests.Toy `gorm:"polymorphic:Owner"`
    	CompanyID *int
    	Company   *tests.Company
    	ManagerID *uint
    	Manager   *User
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  9. tests/main_test.go

    		t.Errorf("Should got error with invalid SQL")
    	}
    
    	var count1, count2 int64
    	DB.Model(&User{}).Count(&count1)
    	if count1 <= 0 {
    		t.Errorf("Should find some users")
    	}
    
    	if DB.Where("name = ?", "jinzhu; delete * from users").First(&User{}).Error == nil {
    		t.Errorf("Should got error with invalid SQL")
    	}
    
    	DB.Model(&User{}).Count(&count2)
    	if count1 != count2 {
    		t.Errorf("No user should not be deleted by invalid SQL")
    	}
    }
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 24 01:31:58 GMT 2022
    - 1.4K bytes
    - Viewed (0)
  10. errors.go

    	ErrInvalidValueOfLength = errors.New("invalid association values, length doesn't match")
    	// ErrPreloadNotAllowed preload is not allowed when count is used
    	ErrPreloadNotAllowed = errors.New("preload is not allowed when count is used")
    	// ErrDuplicatedKey occurs when there is a unique key constraint violation
    	ErrDuplicatedKey = errors.New("duplicated key not allowed")
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 02:53:17 GMT 2024
    - 2.5K bytes
    - Viewed (0)
Back to top