- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 71 for db (0.2 sec)
-
callbacks/associations.go
} if saveAssociations(db, rel, rv, selectColumns, restricted, nil) == nil { setupReferences(db.Statement.ReflectValue, rv) } } } } } } } func SaveAfterAssociations(create bool) func(db *gorm.DB) { return func(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil { selectColumns, restricted := db.Statement.SelectAndOmitColumns(create, !create)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Tue Apr 11 03:06:13 UTC 2023 - 14.3K bytes - Viewed (0) -
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/associations_test.go
parent := Parent{} DB.Create(&parent) child := Child{ParentID: &parent.ID, Parent: &parent} DB.Create(&child) parent.FavChildID = child.ID parent.FavChild = &child DB.Save(&parent) var parent1 Parent DB.First(&parent1, parent.ID) AssertObjEqual(t, parent, parent1, "ID", "FavChildID") // Save and Updates is the same DB.Updates(&parent) DB.First(&parent1, parent.ID)
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Wed Feb 08 08:29:09 UTC 2023 - 10.9K bytes - Viewed (0) -
callbacks/create.go
// BeforeCreate before create hooks func BeforeCreate(db *gorm.DB) { if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeCreate) { callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) { if db.Statement.Schema.BeforeSave { if i, ok := value.(BeforeSaveInterface); ok { called = true db.AddError(i.BeforeSave(tx)) } }
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Mon Apr 08 03:29:55 UTC 2024 - 12.5K 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/multi_primary_keys_test.go
} func TestManyToManyWithMultiPrimaryKeys(t *testing.T) { if name := DB.Dialector.Name(); name == "sqlite" || name == "sqlserver" { t.Skip("skip sqlite, sqlserver due to it doesn't support multiple primary keys with auto increment") } if name := DB.Dialector.Name(); name == "postgres" { stmt := gorm.Statement{DB: DB} stmt.Parse(&Blog{}) stmt.Schema.LookUpField("ID").Unique = true stmt.Parse(&Tag{})
Registered: Sun Nov 03 09:35:10 UTC 2024 - Last Modified: Thu Jan 06 07:02:53 UTC 2022 - 12.8K 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)