Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for black (0.15 sec)

  1. tests/prepared_stmt_test.go

    )
    
    func TestPreparedStmt(t *testing.T) {
    	tx := DB.Session(&gorm.Session{PrepareStmt: true})
    
    	if _, ok := tx.ConnPool.(*gorm.PreparedStmtDB); !ok {
    		t.Fatalf("should assign PreparedStatement Manager back to database when using PrepareStmt mode")
    	}
    
    	ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
    	defer cancel()
    	txCtx := tx.WithContext(ctx)
    
    	user := *GetUser("prepared_stmt", Config{})
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Mar 21 07:55:43 GMT 2024
    - 4K bytes
    - Viewed (0)
  2. tests/embedded_struct_test.go

    	}
    
    	if hnPost.Title != "embedded_pointer_type" {
    		t.Errorf("Should find correct value for embedded pointer type")
    	}
    
    	if hnPost.Author != nil {
    		t.Errorf("Expected to get back a nil Author but got: %v", hnPost.Author)
    	}
    
    	now := time.Now().Round(time.Second)
    	NewPost := HNPost{
    		BasePost: &BasePost{Title: "embedded_pointer_type2"},
    		Author: &Author{
    			Name:        "test",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Oct 26 03:58:13 GMT 2023
    - 7.3K bytes
    - Viewed (0)
  3. tests/postgres_test.go

    		t.Fatalf("Failed to migrate for uuid default value, got error: %v", err)
    	}
    
    	harumph := Harumph{}
    	if err := DB.Create(&harumph).Error; err == nil {
    		t.Fatalf("should failed to create data, name can't be blank")
    	}
    
    	harumph = Harumph{Name: "jinzhu"}
    	if err := DB.Create(&harumph).Error; err != nil {
    		t.Fatalf("should be able to create data, but got %v", err)
    	}
    
    	var result Harumph
    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)
  4. 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)
  5. finisher_api.go

    				// Make sure to rollback when panic, Block error or Commit error
    				if panicked || err != nil {
    					db.RollbackTo(fmt.Sprintf("sp%p", fc))
    				}
    			}()
    		}
    		err = fc(db.Session(&Session{NewDB: db.clone == 1}))
    	} else {
    		tx := db.Begin(opts...)
    		if tx.Error != nil {
    			return tx.Error
    		}
    
    		defer func() {
    			// Make sure to rollback when panic, Block error or Commit error
    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)
  6. tests/transaction_test.go

    		t.Fatalf("Transaction return error will equal the block returns error")
    	}
    
    	if err := DB.First(&User{}, "name = ?", "transaction-block").Error; err == nil {
    		t.Fatalf("Should not find record after rollback")
    	}
    
    	// commit
    	DB.Transaction(func(tx *gorm.DB) error {
    		user := *GetUser("transaction-block-2", Config{})
    		if err := tx.Save(&user).Error; err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  7. tests/update_test.go

    		t.Errorf("account number should not been changed, expects: %v, got %v", user.Account.Number, result.Account.Number)
    	}
    }
    
    func TestUpdatesWithBlankValues(t *testing.T) {
    	user := *GetUser("updates_with_blank_value", Config{})
    	DB.Save(&user)
    
    	var user2 User
    	user2.ID = user.ID
    	DB.Model(&user2).Updates(&User{Age: 100})
    
    	var result User
    	DB.First(&result, user.ID)
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Dec 04 03:50:58 GMT 2023
    - 30.3K bytes
    - Viewed (0)
  8. tests/non_std_test.go

    		t.Errorf("Update a filed with a default value should occur. But got %v\n", animal.Name)
    	}
    
    	// When changing a field with a default value with blank value
    	animal.Name = ""
    	DB.Save(&animal)
    	DB.First(&animal, animal.Counter)
    	if animal.Name != "" {
    		t.Errorf("Update a filed to blank with a default value should occur. But got %v\n", animal.Name)
    	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 1.9K bytes
    - Viewed (0)
  9. association.go

    }
    
    func (association *Association) saveAssociation(clear bool, values ...interface{}) {
    	var (
    		reflectValue = association.DB.Statement.ReflectValue
    		assignBacks  []assignBack // assign association values back to arguments after save
    	)
    
    	appendToRelations := func(source, rv reflect.Value, clear bool) {
    		switch association.Relationship.Type {
    		case schema.HasOne, schema.BelongsTo:
    			switch rv.Kind() {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu May 04 11:30:45 GMT 2023
    - 21.2K bytes
    - Viewed (0)
  10. schema/field.go

    		field.Precision, _ = strconv.Atoi(p)
    	}
    
    	if s, ok := field.TagSettings["SCALE"]; ok {
    		field.Scale, _ = strconv.Atoi(s)
    	}
    
    	// default value is function or null or blank (primary keys)
    	field.DefaultValue = strings.TrimSpace(field.DefaultValue)
    	skipParseDefaultValue := strings.Contains(field.DefaultValue, "(") &&
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 32K bytes
    - Viewed (1)
Back to top