- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 79 for DB (0.03 sec)
-
chainable_api.go
// func AmountGreaterThan1000(db *gorm.DB) *gorm.DB { // return db.Where("amount > ?", 1000) // } // // func OrderStatus(status []string) func (db *gorm.DB) *gorm.DB { // return func (db *gorm.DB) *gorm.DB { // return db.Scopes(AmountGreaterThan1000).Where("status in (?)", status) // } // } // // db.Scopes(AmountGreaterThan1000, OrderStatus([]string{"paid", "shipped"})).Find(&orders)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 24 09:42:59 UTC 2024 - 14.8K bytes - Viewed (0) -
scan.go
v, ok := db.Statement.ColumnMapping[column] if ok { columns[i] = v } } } db.RowsAffected = 0 switch dest := db.Statement.Dest.(type) { case map[string]interface{}, *map[string]interface{}: if initialized || rows.Next() { columnTypes, _ := rows.ColumnTypes() prepareValues(values, db, columnTypes, columns) db.RowsAffected++ db.AddError(rows.Scan(values...))
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 24 09:42:59 UTC 2024 - 10.1K bytes - Viewed (0) -
tests/joins_test.go
user := *GetUser("joins-on", Config{Pets: 2}) DB.Save(&user) var user1 User onQuery := DB.Where(&Pet{Name: "joins-on_pet_1"}) if err := DB.Joins("NamedPet", onQuery).Where("users.name = ?", user.Name).First(&user1).Error; err != nil { t.Fatalf("Failed to load with joins on, got error: %v", err) } AssertEqual(t, user1.NamedPet.Name, "joins-on_pet_1") onQuery2 := DB.Where(&Pet{Name: "joins-on_pet_2"})
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 17 03:58:13 UTC 2024 - 15K bytes - Viewed (0) -
tests/tests_test.go
if dbDSN == "" { dbDSN = sqlserverDSN } db, err = gorm.Open(sqlserver.Open(dbDSN), cfg) case "tidb": log.Println("testing tidb...") if dbDSN == "" { dbDSN = tidbDSN } db, err = gorm.Open(mysql.Open(dbDSN), cfg) default: log.Println("testing sqlite3...") db, err = gorm.Open(sqlite.Open(filepath.Join(os.TempDir(), "gorm.db")), cfg) if err == nil { db.Exec("PRAGMA foreign_keys = ON") } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Sep 30 03:21:19 UTC 2024 - 3.3K bytes - Viewed (0) -
gorm.go
if errTranslator, ok := db.Dialector.(ErrorTranslator); ok { err = errTranslator.Translate(err) } } if db.Error == nil { db.Error = err } else { db.Error = fmt.Errorf("%v; %w", db.Error, err) } } return db.Error } // DB returns `*sql.DB` func (db *DB) DB() (*sql.DB, error) { connPool := db.ConnPool if db.Statement != nil && db.Statement.ConnPool != nil {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Oct 09 11:29:48 UTC 2024 - 12.1K bytes - Viewed (0) -
callbacks/query.go
"gorm.io/gorm/schema" "gorm.io/gorm/utils" ) func Query(db *gorm.DB) { if db.Error == nil { BuildQuerySQL(db) if !db.DryRun && db.Error == nil { rows, err := db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...) if err != nil { db.AddError(err) return } defer func() { db.AddError(rows.Close()) }() gorm.Scan(rows, db, 0) } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Aug 22 11:03:42 UTC 2024 - 10.1K bytes - Viewed (1) -
tests/preload_test.go
CheckUser(t, u, users[i]) } var user4 User DB.Delete(&users3[0].Account) if err := DB.Preload(clause.Associations).Take(&user4, "id = ?", users3[0].ID).Error; err != nil || user4.Account.ID != 0 { t.Errorf("failed to query, got error %v, account: %#v", err, user4.Account) } if err := DB.Preload(clause.Associations, func(tx *gorm.DB) *gorm.DB { return tx.Unscoped()
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jun 12 10:00:47 UTC 2024 - 15.9K bytes - Viewed (0) -
finisher_api.go
func (db *DB) Create(value interface{}) (tx *DB) { if db.CreateBatchSize > 0 { return db.CreateInBatches(value, db.CreateBatchSize) } tx = db.getInstance() tx.Statement.Dest = value return tx.callbacks.Create().Execute(tx) } // CreateInBatches inserts value in batches of batchSize func (db *DB) CreateInBatches(value interface{}, batchSize int) (tx *DB) {
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Sat Sep 14 12:58:29 UTC 2024 - 22.8K bytes - Viewed (0) -
callbacks/preload.go
tx := db.Session(&gorm.Session{Context: db.Statement.Context, NewDB: true, SkipHooks: db.Statement.SkipHooks, Initialized: true}) db.Statement.Settings.Range(func(k, v interface{}) bool { tx.Statement.Settings.Store(k, v) return true }) if err := tx.Statement.Parse(dest); err != nil { tx.AddError(err) return tx } tx.Statement.ReflectValue = reflectValue
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Jun 12 10:52:33 UTC 2024 - 11.6K bytes - Viewed (0) -
tests/hooks_test.go
DB.Migrator().DropTable(&Product{}) DB.AutoMigrate(&Product{}) p := Product{Code: "Invalid", Price: 100} if DB.Save(&p).Error == nil { t.Fatalf("An error from before create callbacks happened when create with invalid value") } if DB.Where("code = ?", "Invalid").First(&Product{}).Error == nil { t.Fatalf("Should not save record that have errors") }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Jun 17 03:59:06 UTC 2024 - 16.7K bytes - Viewed (0)