Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 24 for KSession (2.86 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/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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. migrator/migrator.go

    		}
    	}
    
    	return
    }
    
    func (m Migrator) GetQueryAndExecTx() (queryTx, execTx *gorm.DB) {
    	queryTx = m.DB.Session(&gorm.Session{})
    	execTx = queryTx
    	if m.DB.DryRun {
    		queryTx.DryRun = false
    		execTx = m.DB.Session(&gorm.Session{Logger: &printSQLLogger{Interface: m.DB.Logger}})
    	}
    	return queryTx, execTx
    }
    
    // AutoMigrate auto migrate values
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  8. finisher_api.go

    		if !selectedUpdate {
    			tx.Statement.Selects = append(tx.Statement.Selects, "*")
    		}
    
    		updateTx := tx.callbacks.Update().Execute(tx.Session(&Session{Initialized: true}))
    
    		if updateTx.Error == nil && updateTx.RowsAffected == 0 && !updateTx.DryRun && !selectedUpdate {
    			return tx.Session(&Session{SkipHooks: true}).Clauses(clause.OnConflict{UpdateAll: true}).Create(value)
    		}
    
    		return updateTx
    	}
    
    	return
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
  9. migrator.go

    func (db *DB) Migrator() Migrator {
    	tx := db.getInstance()
    
    	// apply scopes to migrator
    	for len(tx.Statement.scopes) > 0 {
    		tx = tx.executeScopes()
    	}
    
    	return tx.Dialector.Migrator(tx.Session(&Session{}))
    }
    
    // AutoMigrate run auto migration for given models
    func (db *DB) AutoMigrate(dst ...interface{}) error {
    	return db.Migrator().AutoMigrate(dst...)
    }
    
    // ViewOption view option
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 3.1K bytes
    - Viewed (0)
  10. tests/gorm_test.go

    			t.Fatalf("rows affected expects: %v, got %v", 1, results.RowsAffected)
    		}
    
    		u1 = user{} // important to reinitialize this before creating it again
    		u2 := user{}
    		db := DB.Session(&gorm.Session{CreateBatchSize: 10})
    
    		if results := db.Create([]*user{&u1, &u2}); results.Error != nil {
    			t.Fatalf("errors happened on create: %v", results.Error)
    		} else if results.RowsAffected != 2 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jun 01 07:22:21 GMT 2023
    - 3.3K bytes
    - Viewed (0)
Back to top