Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for UpdateColumn (0.12 sec)

  1. tests/sql_builder_test.go

    	})
    	assertEqualSQL(t, `UPDATE "users" SET "name"='Foo bar',"updated_at"='2021-10-18 19:50:09.438' WHERE id = 100 AND "users"."deleted_at" IS NULL`, sql)
    
    	// UpdateColumn
    	sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
    		return tx.Model(&User{}).Where("id = ?", 100).UpdateColumn("name", "Foo bar")
    	})
    	assertEqualSQL(t, `UPDATE "users" SET "name"='Foo bar' WHERE id = 100 AND "users"."deleted_at" IS NULL`, sql)
    
    	// UpdateColumns
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 16.7K bytes
    - Viewed (0)
  2. tests/update_test.go

    	var user1, user2 User
    	DB.First(&user1, users[0].ID)
    	DB.First(&user2, users[1].ID)
    	CheckUser(t, user1, *users[0])
    	CheckUser(t, user2, *users[1])
    
    	DB.Model(users[1]).UpdateColumn("name", "update_column_02_newnew").UpdateColumn("age", 19)
    	AssertEqual(t, lastUpdatedAt.UnixNano(), users[1].UpdatedAt.UnixNano())
    
    	if users[1].Name != "update_column_02_newnew" {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Dec 04 03:50:58 UTC 2023
    - 30.3K bytes
    - Viewed (0)
  3. tests/hooks_test.go

    	return
    }
    
    func (s *Product) AfterFind(tx *gorm.DB) (err error) {
    	s.AfterFindCallTimes = s.AfterFindCallTimes + 1
    	return
    }
    
    func (s *Product) AfterCreate(tx *gorm.DB) (err error) {
    	return tx.Model(s).UpdateColumn("AfterCreateCallTimes", s.AfterCreateCallTimes+1).Error
    }
    
    func (s *Product) AfterUpdate(tx *gorm.DB) (err error) {
    	s.AfterUpdateCallTimes = s.AfterUpdateCallTimes + 1
    	return
    }
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Jun 17 03:59:06 UTC 2024
    - 16.7K bytes
    - Viewed (0)
  4. finisher_api.go

    func (db *DB) Updates(values interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Dest = values
    	return tx.callbacks.Update().Execute(tx)
    }
    
    func (db *DB) UpdateColumn(column string, value interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Dest = map[string]interface{}{column: value}
    	tx.Statement.SkipHooks = true
    	return tx.callbacks.Update().Execute(tx)
    }
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Sat Sep 14 12:58:29 UTC 2024
    - 22.8K bytes
    - Viewed (0)
Back to top