Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 55 for udpate (0.2 sec)

  1. tests/update_test.go

    	users := []*User{
    		GetUser("update_column_01", Config{}),
    		GetUser("update_column_02", Config{}),
    	}
    
    	DB.Create(&users)
    	lastUpdatedAt := users[1].UpdatedAt
    
    	// update with map
    	DB.Model(users[1]).UpdateColumns(map[string]interface{}{"name": "update_column_02_newname", "age": 100})
    	if users[1].Name != "update_column_02_newname" || users[1].Age != 100 {
    		t.Errorf("user 2 should be updated with update column")
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  2. tests/update_many2many_test.go

    	if err := DB.Save(&user).Error; err != nil {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user3 User
    	DB.Preload("Languages").Preload("Friends").Find(&user3, "id = ?", user.ID)
    	CheckUser(t, user2, user3)
    
    	if err := DB.Session(&gorm.Session{FullSaveAssociations: true}).Save(&user).Error; err != nil {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user4 User
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.3K bytes
    - Viewed (0)
  3. tests/scanner_valuer_test.go

    	}
    
    	if err := DB.Model(&data).Update("password", EncryptedData("xnewpass")).Error; err == nil {
    		t.Errorf("Should failed to update data with invalid data")
    	}
    
    	if err := DB.Model(&data).Update("password", EncryptedData("newpass")).Error; err != nil {
    		t.Errorf("Should got no error update data with valid data, but got %v", err)
    	}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Jun 07 07:02:07 GMT 2023
    - 10.6K bytes
    - Viewed (0)
  4. .github/workflows/invalid_question.yml

            stale-issue-label: "status:stale"
            days-before-stale: 0
            days-before-close: 30
            remove-stale-when-updated: true
    Others
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Apr 11 02:27:05 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  5. tests/hooks_test.go

    	}
    	if beforeUpdateCall != 1 {
    		t.Fatalf("before update should not be called")
    	}
    
    	err = DB.Model([1]*Product5{&p}).Update("name", "update_name_3").Error
    	if err != nil {
    		t.Fatalf("should update success, but got err %v", err)
    	}
    	if beforeUpdateCall != 2 {
    		t.Fatalf("before update should be called")
    	}
    
    	err = DB.Model([1]Product5{p}).Update("name", "update_name_4").Error
    	if !errors.Is(err, gorm.ErrInvalidValue) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  6. tests/upsert_test.go

    		t.Fatalf("failed to onconflict create user, got error %v", err)
    	} else {
    		var user3 User
    		DB.First(&user3, user.ID)
    		if user3.UpdatedAt.UnixNano() == user2.UpdatedAt.UnixNano() {
    			t.Fatalf("failed to update user's updated_at, old: %v, new: %v", user2.UpdatedAt, user3.UpdatedAt)
    		}
    	}
    }
    
    func TestUpsertSlice(t *testing.T) {
    	langs := []Language{
    		{Code: "upsert-slice1", Name: "Upsert-slice1"},
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  7. chainable_api.go

    	"gorm.io/gorm/utils"
    )
    
    // Model specify the model you would like to run db operations
    //
    //	// update all users's name to `hello`
    //	db.Model(&User{}).Update("name", "hello")
    //	// if user's primary key is non-blank, will use it as condition, then will only update that user's name to `hello`
    //	db.Model(&user).Update("name", "hello")
    func (db *DB) Model(value interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Model = value
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  8. callbacks/update.go

    				if i, ok := value.(BeforeUpdateInterface); ok {
    					called = true
    					db.AddError(i.BeforeUpdate(tx))
    				}
    			}
    
    			return called
    		})
    	}
    }
    
    // Update update hook
    func Update(config *Config) func(db *gorm.DB) {
    	supportReturning := utils.Contains(config.UpdateClauses, "RETURNING")
    
    	return func(db *gorm.DB) {
    		if db.Error != nil {
    			return
    		}
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 05:44:55 GMT 2024
    - 9.4K bytes
    - Viewed (1)
  9. soft_delete.go

    				}
    			}
    		}
    
    		SoftDeleteQueryClause(sd).ModifyStatement(stmt)
    		stmt.AddClauseIfNotExists(clause.Update{})
    		stmt.Build(stmt.DB.Callback().Update().Clauses...)
    	}
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 4.5K bytes
    - Viewed (0)
  10. clause/locking.go

    package clause
    
    const (
    	LockingStrengthUpdate    = "UPDATE"
    	LockingStrengthShare     = "SHARE"
    	LockingOptionsSkipLocked = "SKIP LOCKED"
    	LockingOptionsNoWait     = "NOWAIT"
    )
    
    type Locking struct {
    	Strength string
    	Table    Table
    	Options  string
    }
    
    // Name where clause name
    func (locking Locking) Name() string {
    	return "FOR"
    }
    
    // Build build where clause
    func (locking Locking) Build(builder Builder) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:32:56 GMT 2023
    - 773 bytes
    - Viewed (0)
Back to top