Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 34 for KSession (0.31 sec)

  1. callbacks/callmethod.go

    package callbacks
    
    import (
    	"reflect"
    
    	"gorm.io/gorm"
    )
    
    func callMethod(db *gorm.DB, fc func(value interface{}, tx *gorm.DB) bool) {
    	tx := db.Session(&gorm.Session{NewDB: true})
    	if called := fc(db.Statement.ReflectValue.Interface(), tx); !called {
    		switch db.Statement.ReflectValue.Kind() {
    		case reflect.Slice, reflect.Array:
    			db.Statement.CurDestIndex = 0
    			for i := 0; i < db.Statement.ReflectValue.Len(); i++ {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 846 bytes
    - Viewed (0)
  2. tests/scanner_valuer_test.go

    	}
    }
    
    func TestGORMValuer(t *testing.T) {
    	type UserWithPoint struct {
    		Name  string
    		Point Point
    	}
    
    	dryRunDB := DB.Session(&gorm.Session{DryRun: true})
    
    	stmt := dryRunDB.Create(&UserWithPoint{
    		Name:  "jinzhu",
    		Point: Point{X: 100, Y: 100},
    	}).Statement
    
    	if stmt.SQL.String() == "" || len(stmt.Vars) != 2 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Jun 07 07:02:07 GMT 2023
    - 10.6K bytes
    - Viewed (0)
  3. tests/update_test.go

    	}
    
    	dryDB := DB.Session(&gorm.Session{DryRun: true})
    	stmt := dryDB.Save(&user).Statement
    	if !regexp.MustCompile(`.users.\..deleted_at. IS NULL`).MatchString(stmt.SQL.String()) {
    		t.Fatalf("invalid updating SQL, got %v", stmt.SQL.String())
    	}
    
    	dryDB = DB.Session(&gorm.Session{DryRun: true})
    	stmt = dryDB.Unscoped().Save(&user).Statement
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  4. tests/preload_test.go

    func TestPreloadGoroutine(t *testing.T) {
    	var wg sync.WaitGroup
    
    	wg.Add(10)
    	for i := 0; i < 10; i++ {
    		go func() {
    			defer wg.Done()
    			var user2 []User
    			tx := DB.Where("id = ?", 1).Session(&gorm.Session{})
    
    			if err := tx.Preload("Team").Find(&user2).Error; err != nil {
    				t.Error(err)
    			}
    		}()
    	}
    	wg.Wait()
    }
    
    func TestPreloadWithDiffModel(t *testing.T) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 14.9K bytes
    - Viewed (0)
  5. callbacks/preload.go

    						return err
    					}
    				default:
    					return gorm.ErrInvalidData
    				}
    			} else {
    				tx := db.Table("").Session(&gorm.Session{Context: db.Statement.Context, SkipHooks: db.Statement.SkipHooks})
    				tx.Statement.ReflectValue = db.Statement.ReflectValue
    				tx.Statement.Unscoped = db.Statement.Unscoped
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  6. tests/associations_belongs_to_test.go

    }
    
    func TestBelongsToDefaultValue(t *testing.T) {
    	type Org struct {
    		ID string
    	}
    	type BelongsToUser struct {
    		OrgID string
    		Org   Org `gorm:"default:NULL"`
    	}
    
    	tx := DB.Session(&gorm.Session{})
    	tx.Config.DisableForeignKeyConstraintWhenMigrating = true
    	AssertEqual(t, DB.Config.DisableForeignKeyConstraintWhenMigrating, false)
    
    	tx.Migrator().DropTable(&BelongsToUser{}, &Org{})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
  7. tests/delete_test.go

    	if err := DB.Delete(&User{}).Error; err == nil || !errors.Is(err, gorm.ErrMissingWhereClause) {
    		t.Errorf("should returns missing WHERE clause while deleting error")
    	}
    
    	if err := DB.Session(&gorm.Session{AllowGlobalUpdate: true}).Delete(&User{}).Error; err != nil {
    		t.Errorf("should returns no error while enable global update, but got err %v", err)
    	}
    }
    
    func TestDeleteWithAssociations(t *testing.T) {
    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)
  8. statement.go

    			if len(v) > 0 {
    				writer.WriteByte('(')
    				stmt.AddVar(writer, v...)
    				writer.WriteByte(')')
    			} else {
    				writer.WriteString("(NULL)")
    			}
    		case *DB:
    			subdb := v.Session(&Session{Logger: logger.Discard, DryRun: true}).getInstance()
    			if v.Statement.SQL.Len() > 0 {
    				var (
    					vars = subdb.Statement.Vars
    					sql  = v.Statement.SQL.String()
    				)
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 19.8K bytes
    - Viewed (0)
  9. gorm.go

    }
    
    // DB GORM DB definition
    type DB struct {
    	*Config
    	Error        error
    	RowsAffected int64
    	Statement    *Statement
    	clone        int
    }
    
    // Session session config when create session with Session() method
    type Session struct {
    	DryRun                   bool
    	PrepareStmt              bool
    	NewDB                    bool
    	Initialized              bool
    	SkipHooks                bool
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Aug 20 11:46:56 GMT 2023
    - 11.6K bytes
    - Viewed (0)
  10. tests/query_test.go

    	result := DB.Session(&gorm.Session{DryRun: true}).Model(&User{}).Find(&simpleUsers, user.ID)
    
    	if !regexp.MustCompile("SELECT .*id.*name.*updated_at.*created_at.* FROM .*users").MatchString(result.Statement.SQL.String()) {
    		t.Fatalf("SQL should include selected names, but got %v", result.Statement.SQL.String())
    	}
    
    	result = DB.Session(&gorm.Session{DryRun: true}).Model(&User{}).Find(&User{}, user.ID)
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
Back to top