Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 48 for Errorf (0.08 sec)

  1. tests/non_std_test.go

    	DB.First(&animal, animal.Counter)
    	if animal.Name != "amazing horse" {
    		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)
    	}
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed May 08 04:07:58 UTC 2024
    - 1.9K bytes
    - Viewed (0)
  2. tests/sql_builder_test.go

    	if err != nil {
    		t.Errorf("Not error should happen, got %v", err)
    	}
    
    	count := 0
    	for rows.Next() {
    		var name string
    		var age int64
    		rows.Scan(&name, &age)
    		count++
    	}
    
    	if count != 2 {
    		t.Errorf("Should found two records")
    	}
    }
    
    func TestRaw(t *testing.T) {
    	user1 := User{Name: "ExecRawSqlUser1", Age: 1}
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 16.7K bytes
    - Viewed (0)
  3. statement_test.go

    				Exprs: s.BuildCondition("FINAL2"),
    			})
    
    			if reflect.DeepEqual(s1.Clauses["WHERE"], s2.Clauses["WHERE"]) {
    				t.Errorf("Where conditions should be different")
    			}
    		})
    	}
    }
    
    func TestNilCondition(t *testing.T) {
    	s := new(Statement)
    	if len(s.BuildCondition(nil)) != 0 {
    		t.Errorf("Nil condition should be empty")
    	}
    }
    
    func TestNameMatcher(t *testing.T) {
    	for k, v := range map[string][]string{
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Sat Dec 23 13:19:41 UTC 2023
    - 1.9K bytes
    - Viewed (0)
  4. schema/relationship.go

    	}
    
    	if relation.Polymorphic.PolymorphicType == nil {
    		schema.err = fmt.Errorf("invalid polymorphic type %v for %v on field %s, missing field %s",
    			relation.FieldSchema, schema, field.Name, polymorphic+"Type")
    	}
    
    	if relation.Polymorphic.PolymorphicID == nil {
    		schema.err = fmt.Errorf("invalid polymorphic type %v for %v on field %s, missing field %s",
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 03:46:59 UTC 2024
    - 22.7K bytes
    - Viewed (0)
  5. tests/associations_has_many_test.go

    	}
    
    	if count := tx.Model(&item).Association("Contents").Count(); count != 3 {
    		t.Errorf("expected %d contents, got %d", 3, count)
    	}
    
    	var contents []ItemContent
    	if err := tx.Find(&contents).Error; err != nil {
    		t.Errorf("failed to find contents, got error: %v", err)
    	}
    	if len(contents) != 3 {
    		t.Errorf("expected %d contents, got %d", 3, len(contents))
    	}
    
    	// test delete
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 16K bytes
    - Viewed (0)
  6. schema/schema_helper_test.go

    			if r.Name != relation.Name {
    				t.Errorf("schema %v relation name expects %v, but got %v", s, r.Name, relation.Name)
    			}
    
    			if r.Type != relation.Type {
    				t.Errorf("schema %v relation name expects %v, but got %v", s, r.Type, relation.Type)
    			}
    
    			if r.Schema.Name != relation.Schema {
    				t.Errorf("schema %v relation's schema expects %v, but got %v", s, relation.Schema, r.Schema.Name)
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Fri Dec 15 08:31:23 UTC 2023
    - 7.5K bytes
    - Viewed (0)
  7. tests/prepared_stmt_test.go

    			tx.Rollback()
    		}
    	}()
    	if err := tx.Error; err != nil {
    		t.Errorf("Failed to start transaction, got error %v\n", err)
    	}
    
    	if err := tx.Where("name=?", "zzjin").Delete(&User{}).Error; err != nil {
    		tx.Rollback()
    		t.Errorf("Failed to run one transaction, got error %v\n", err)
    	}
    
    	if err := tx.Create(&User{Name: "zzjin"}).Error; err != nil {
    		tx.Rollback()
    		t.Errorf("Failed to run one transaction, got error %v\n", err)
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Thu Mar 21 07:55:43 UTC 2024
    - 4K bytes
    - Viewed (0)
  8. tests/associations_has_one_test.go

    	user := User{Name: "jinzhu", Account: Account{Number: "1"}}
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	if err := DB.Model(&user).Association("Languages").Replace(Account{Number: "2"}); err == nil {
    		t.Error("expected association error to be not nil")
    	}
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 7.1K bytes
    - Viewed (0)
  9. callbacks/create_test.go

    		Name  string
    		Email string `gorm:"default:(-)"`
    		Age   int    `gorm:"default:(-)"`
    	}
    
    	s, err := schema.Parse(&user{}, schemaCache, schema.NamingStrategy{})
    	if err != nil {
    		t.Errorf("parse schema error: %v, is not expected", err)
    		return
    	}
    	dest := []*user{
    		{
    			ID:    1,
    			Name:  "alice",
    			Email: "email",
    			Age:   18,
    		},
    		{
    			ID:    2,
    			Name:  "bob",
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Mon Mar 18 05:48:42 UTC 2024
    - 1.4K bytes
    - Viewed (0)
  10. callbacks/query.go

    		db.Statement.AddClauseIfNotExists(clauseSelect)
    
    		db.Statement.Build(db.Statement.BuildClauses...)
    	}
    }
    
    func Preload(db *gorm.DB) {
    	if db.Error == nil && len(db.Statement.Preloads) > 0 {
    		if db.Statement.Schema == nil {
    			db.AddError(fmt.Errorf("%w when using preload", gorm.ErrModelValueRequired))
    			return
    		}
    
    		joins := make([]string, 0, len(db.Statement.Joins))
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 09:51:44 UTC 2024
    - 10.1K bytes
    - Viewed (0)
Back to top