- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 1,772 for user4 (0.04 sec)
-
tests/upsert_test.go
- if user6.Name != "find or init" || user6.ID == 0 || user6.Age != 44 {
- t.Errorf("user should be found and updated with assigned attrs")
- }
- }
- func TestFindOrCreate(t *testing.T) {
- var user1, user2, user3, user4, user5, user6, user7, user8 User
- if err := DB.Where(&User{Name: "find or create", Age: 33}).FirstOrCreate(&user1).Error; err != nil {
- t.Errorf("no error should happen when FirstOrInit, but got %v", err)
- }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Sep 05 07:39:19 UTC 2022 - 11.4K bytes - Viewed (0) -
tests/update_has_many_test.go
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jan 06 07:02:53 UTC 2022 - 2K bytes - Viewed (0) -
tests/preload_test.go
- }
- var user4 *User
- DB.Preload("Pets.Toy").Find(&user4, "id = ?", user.ID)
- if len(user4.Pets) != 0 {
- t.Fatalf("User.Pet[0] was deleted and should not exist.")
- }
- var user5 User
- DB.Unscoped().Preload(clause.Associations+"."+clause.Associations).Find(&user5, "id = ?", user.ID)
- CheckUserUnscoped(t, user5, user)
- var user6 *User
- DB.Unscoped().Preload("Pets.Toy").Find(&user6, "id = ?", user.ID)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jun 12 10:00:47 UTC 2024 - 15.9K bytes - Viewed (0) -
tests/update_belongs_to_test.go
- var user2 User
- DB.Preload("Company").Preload("Manager").Find(&user2, "id = ?", user.ID)
- CheckUser(t, user2, user)
- user.Company.Name += "new"
- user.Manager.Name += "new"
- if err := DB.Save(&user).Error; err != nil {
- t.Fatalf("errors happened when update: %v", err)
- }
- var user3 User
- DB.Preload("Company").Preload("Manager").Find(&user3, "id = ?", user.ID)
- CheckUser(t, user2, user3)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jul 14 06:55:54 UTC 2022 - 1.6K bytes - Viewed (0) -
tests/update_many2many_test.go
- }
- var user3 User
- DB.Preload("Languages").Preload("Friends").Find(&user3, "id = ?", user.ID)
- CheckUser(t, user2, user3)
- if err := DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&user).Error; err != nil {
- t.Fatalf("errors happened when update: %v", err)
- }
- var user4 User
- DB.Preload("Languages").Preload("Friends").Find(&user4, "id = ?", user.ID)
- CheckUser(t, user4, user)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jan 06 07:02:53 UTC 2022 - 1.3K bytes - Viewed (0) -
tests/update_has_one_test.go
- CheckUser(t, user2, user)
- user.Account.Number += "new"
- if err := DB.Save(&user).Error; err != nil {
- t.Fatalf("errors happened when update: %v", err)
- }
- var user3 User
- DB.Preload("Account").Find(&user3, "id = ?", user.ID)
- CheckUser(t, user2, user3)
- lastUpdatedAt := user2.Account.UpdatedAt
- time.Sleep(time.Second)
- if err := DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&user).Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jul 14 06:55:54 UTC 2022 - 3.6K bytes - Viewed (0) -
tests/joins_test.go
- if user1.NamedPet == nil || user1.Account.ID == 0 {
- t.Fatalf("joins NamedPet and Account should not empty:%v", user1)
- }
- // Account should empty
- DB.Delete(&user1.Account)
- var user2 User
- DB.Model(&User{}).Joins("NamedPet").Joins("Account").First(&user2, user.ID)
- if user2.NamedPet == nil || user2.Account.ID != 0 {
- t.Fatalf("joins Account should not empty:%v", user2)
- }
- // NamedPet should empty
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 17 03:58:13 UTC 2024 - 15K bytes - Viewed (0) -
tests/update_test.go
- if users[1].Name != "update_column_02_newname" || users[1].Age != 100 {
- t.Errorf("user 2 should be updated with update column")
- }
- AssertEqual(t, lastUpdatedAt.UnixNano(), users[1].UpdatedAt.UnixNano())
- // user2 should not be updated
- var user1, user2 User
- DB.First(&user1, users[0].ID)
- DB.First(&user2, users[1].ID)
- CheckUser(t, user1, *users[0])
- CheckUser(t, user2, *users[1])
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Dec 04 03:50:58 UTC 2023 - 30.3K bytes - Viewed (0) -
tests/scan_test.go
- }
- DB.Table("users").Select("id, name, age").Where("id = ?", user2.ID).Scan(&res)
- if res.ID != user2.ID || res.Name != user2.Name || res.Age != int(user2.Age) {
- t.Fatalf("Scan into struct should work, got %#v, should %#v", res, user2)
- }
- DB.Model(&User{Model: gorm.Model{ID: user3.ID}}).Select("id, name, age").Scan(&res)
- if res.ID != user3.ID || res.Name != user3.Name || res.Age != int(user3.Age) {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jun 12 10:57:36 UTC 2024 - 10.9K bytes - Viewed (0) -
tests/count_test.go
- func TestCount(t *testing.T) {
- var (
- user1 = *GetUser("count-1", Config{})
- user2 = *GetUser("count-2", Config{})
- user3 = *GetUser("count-3", Config{})
- users []User
- count, count1, count2 int64
- )
- DB.Save(&user1).Save(&user2).Save(&user3)
- if err := DB.Where("name = ?", user1.Name).Or("name = ?", user3.Name).Find(&users).Count(&count).Error; err != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Oct 30 09:15:49 UTC 2023 - 6.9K bytes - Viewed (0)