Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 38 for sessions (0.17 sec)

  1. tests/prepared_stmt_test.go

    		tx.Session(&gorm.Session{PrepareStmt: true}).Create(&user)
    		return errors.New("test")
    	}); err == nil {
    		t.Error(err)
    	}
    
    	var result User
    	if err := DB.First(&result, user.ID).Error; err == nil {
    		t.Errorf("Failed, got error: %v", err)
    	}
    }
    
    func TestPreparedStmtReset(t *testing.T) {
    	tx := DB.Session(&gorm.Session{PrepareStmt: true})
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 21 07:55:43 GMT 2024
    - 4K bytes
    - Viewed (0)
  2. tests/update_has_one_test.go

    	}
    
    	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 {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user4 User
    	DB.Preload("Account").Find(&user4, "id = ?", user.ID)
    
    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)
  3. tests/count_test.go

    		t.Errorf("multiple count in chain should works")
    	}
    
    	tx := DB.Model(&User{}).Where("name = ?", user1.Name).Session(&gorm.Session{})
    	tx.Count(&count1)
    	tx.Or("name in ?", []string{user2.Name, user3.Name}).Count(&count2)
    	if count1 != 1 || count2 != 3 {
    		t.Errorf("count after new session should works")
    	}
    
    	var count3 int64
    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)
  4. tests/soft_delete_test.go

    		t.Fatalf("user's deleted at is zero")
    	}
    
    	sql := DB.Session(&gorm.Session{DryRun: true}).Delete(&user).Statement.SQL.String()
    	if !regexp.MustCompile(`UPDATE .users. SET .deleted_at.=.* WHERE .users.\..id. = .* AND .users.\..deleted_at. IS NULL`).MatchString(sql) {
    		t.Fatalf("invalid sql generated, got %v", sql)
    	}
    
    	sql = DB.Session(&gorm.Session{DryRun: true}).Table("user u").Select("name").Find(&User{}).Statement.SQL.String()
    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)
  5. tests/connpool_test.go

    	if err = db.First(&User{}, "name = ?", "transaction").Error; err == nil {
    		t.Fatalf("Should not find record after rollback, but got %v", err)
    	}
    
    	txDB := db.Where("fake_name = ?", "fake_name")
    	tx2 := txDB.Session(&gorm.Session{NewDB: true}).Begin()
    	user2 := *GetUser("transaction-2", Config{})
    	if err = tx2.Save(&user2).Error; err != nil {
    		t.Fatalf("No error should raise, but got %v", err)
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Feb 06 02:54:40 GMT 2024
    - 5.5K bytes
    - Viewed (0)
  6. tests/create_test.go

    		*GetUser("create_with_default_batch_sizs_6", Config{Account: true, Pets: 4, Toys: 3, Company: false, Manager: true, Team: 1, Languages: 3, Friends: 0}),
    	}
    
    	result := DB.Session(&gorm.Session{CreateBatchSize: 2}).Create(&users)
    	if result.RowsAffected != int64(len(users)) {
    		t.Errorf("affected rows should be %v, but got %v", len(users), result.RowsAffected)
    	}
    
    	for _, user := range users {
    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)
  7. tests/joins_test.go

    	if len(users6) != 1 {
    		t.Errorf("should find one users using left join with conditions, but got %v", len(users6))
    	}
    
    	dryDB := DB.Session(&gorm.Session{DryRun: true})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  8. tests/associations_has_many_test.go

    	}
    	type Item struct {
    		gorm.Model
    		Logo     string        `gorm:"not null;type:varchar(50)"`
    		Contents []ItemContent `gorm:"foreignKey:ItemID"`
    	}
    
    	tx := DB.Session(&gorm.Session{})
    	tx.Migrator().DropTable(&ItemContent{}, &Item{})
    	tx.AutoMigrate(&ItemContent{}, &Item{})
    
    	item := Item{
    		Logo: "logo",
    		Contents: []ItemContent{
    			{Name: "name", LanguageCode: "en"},
    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)
  9. callbacks/associations.go

    					}
    
    					for i := 0; i < elemLen; i++ {
    						appendToJoins(objs[i], elems.Index(i))
    					}
    				}
    
    				if joins.Len() > 0 {
    					db.AddError(db.Session(&gorm.Session{NewDB: true}).Clauses(clause.OnConflict{DoNothing: true}).Session(&gorm.Session{
    						SkipHooks:                db.Statement.SkipHooks,
    						DisableNestedTransaction: true,
    					}).Create(joins.Interface()).Error)
    				}
    			}
    		}
    	}
    }
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Apr 11 03:06:13 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  10. tests/scopes_test.go

    	}
    
    	db := DB.Scopes(func(tx *gorm.DB) *gorm.DB {
    		return tx.Table("custom_table")
    	}).Session(&gorm.Session{})
    
    	db.AutoMigrate(&User{})
    	if db.Find(&User{}).Statement.Table != "custom_table" {
    		t.Errorf("failed to call Scopes")
    	}
    
    	result := DB.Scopes(NameIn1And2, func(tx *gorm.DB) *gorm.DB {
    		return tx.Session(&gorm.Session{})
    	}).Find(&users1)
    
    	if result.RowsAffected != 2 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 3.3K bytes
    - Viewed (0)
Back to top