Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 55 for udpate (1.85 sec)

  1. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Sat Feb 18 01:20:29 GMT 2023
    - 15.9K bytes
    - Viewed (0)
  2. clause/update_test.go

    		Result  string
    		Vars    []interface{}
    	}{
    		{
    			[]clause.Interface{clause.Update{}},
    			"UPDATE `users`", nil,
    		},
    		{
    			[]clause.Interface{clause.Update{Modifier: "LOW_PRIORITY"}},
    			"UPDATE LOW_PRIORITY `users`", nil,
    		},
    		{
    			[]clause.Interface{clause.Update{Table: clause.Table{Name: "products"}, Modifier: "LOW_PRIORITY"}},
    			"UPDATE LOW_PRIORITY `products`", nil,
    		},
    	}
    
    	for idx, result := range results {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Jun 02 01:18:01 GMT 2020
    - 722 bytes
    - Viewed (0)
  3. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Mon Sep 05 07:39:19 GMT 2022
    - 11.4K bytes
    - Viewed (0)
  4. tests/update_belongs_to_test.go

    	user := *GetUser("update-belongs-to", Config{})
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	user.Company = Company{Name: "company-belongs-to-association"}
    	user.Manager = &User{Name: "manager-belongs-to-association"}
    	if err := DB.Save(&user).Error; err != nil {
    		t.Fatalf("errors happened when update: %v", err)
    	}
    
    	var user2 User
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jul 14 06:55:54 GMT 2022
    - 1.6K bytes
    - Viewed (0)
  5. tests/customize_field_test.go

    		t.Fatalf("invalid create/update unix nano time: %#v", result)
    	}
    
    	result.FieldAllowUpdate = "field_allow_update_updated"
    	result.FieldReadonly = "field_readonly_updated"
    	result.FieldIgnore = "field_ignore_updated"
    	DB.Save(&result)
    
    	var result2 CustomizeFieldStruct
    	DB.Find(&result2, "name = ?", "create")
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Sep 11 09:33:31 GMT 2020
    - 6.9K bytes
    - Viewed (0)
  6. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  7. soft_delete.go

    				}
    			}
    		}
    
    		SoftDeleteQueryClause(sd).ModifyStatement(stmt)
    		stmt.AddClauseIfNotExists(clause.Update{})
    		stmt.Build(stmt.DB.Callback().Update().Clauses...)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 01 06:40:55 GMT 2023
    - 4.5K bytes
    - Viewed (0)
  8. 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 May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:32:56 GMT 2023
    - 773 bytes
    - Viewed (0)
  9. tests/postgres_test.go

    		t.Errorf("No error should happen, but got %v", err)
    	}
    
    	yasuo.Name = "jinzhu1"
    	if err := DB.Save(&yasuo).Error; err != nil {
    		t.Errorf("Failed to update date, got error %v", err)
    	}
    
    	if err := DB.First(&result, "id = ?", yasuo.ID).Error; err != nil || yasuo.Name != "jinzhu1" {
    		t.Errorf("No error should happen, but got %v", err)
    	}
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Oct 08 09:16:32 GMT 2022
    - 6.4K bytes
    - Viewed (3)
  10. finisher_api.go

    				}
    			}
    		}
    
    		return tx.Model(dest).Updates(assigns)
    	}
    
    	return tx
    }
    
    // Update updates column with value using callbacks. Reference: https://gorm.io/docs/update.html#Update-Changed-Fields
    func (db *DB) Update(column string, value interface{}) (tx *DB) {
    	tx = db.getInstance()
    	tx.Statement.Dest = map[string]interface{}{column: value}
    	return tx.callbacks.Update().Execute(tx)
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
Back to top