Search Options

Results per page
Sort
Preferred Languages
Advance

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

  1. 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 6.8K 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  3. 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 07:03:34 GMT 2023
    - 9.4K bytes
    - Viewed (0)
  4. 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.1K bytes
    - Viewed (0)
  5. 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Thu Jul 14 06:55:54 GMT 2022
    - 3.6K bytes
    - Viewed (0)
  6. 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 Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 2.1K bytes
    - Viewed (0)
  7. 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 21 09:35:09 GMT 2024
    - Last Modified: Wed Jul 08 09:59:40 GMT 2020
    - 4.2K bytes
    - Viewed (0)
  8. 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 21 09:35:09 GMT 2024
    - Last Modified: Thu Sep 10 13:46:18 GMT 2020
    - 3.5K bytes
    - Viewed (0)
  9. tests/tests_test.go

    	} else if debug == "false" {
    		db.Logger = db.Logger.LogMode(logger.Silent)
    	}
    
    	return
    }
    
    func RunMigrations() {
    	var err error
    	allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}, &Coupon{}, &CouponProduct{}, &Order{}, &Parent{}, &Child{}, &Tools{}}
    	rand.Seed(time.Now().UnixNano())
    Go
    - Registered: Sun Apr 21 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 3.3K bytes
    - Viewed (1)
  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 21 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
Back to top