Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 33 for Page (0.16 sec)

  1. tests/scan_test.go

    	doubleAgeRes := &result{}
    	if err := DB.Table("users").Select("age + age as age").Where("id = ?", user3.ID).Scan(&doubleAgeRes).Error; err != nil {
    		t.Errorf("Scan to pointer of pointer")
    	}
    
    	if doubleAgeRes.Age != int(res.Age)*2 {
    		t.Errorf("Scan double age as age, expect: %v, got %v", res.Age*2, doubleAgeRes.Age)
    	}
    
    	var results []result
    	DB.Table("users").Select("name, age").Where("id in ?", []uint{user2.ID, user3.ID}).Scan(&results)
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat May 28 14:18:07 GMT 2022
    - 8.2K bytes
    - Viewed (0)
  2. clause/where_test.go

    			}},
    			"SELECT * FROM `users` WHERE `age` = ? OR `name` <> ?",
    			[]interface{}{18, "jinzhu"},
    		},
    		{
    			[]clause.Interface{clause.Select{}, clause.From{}, clause.Where{
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  3. tests/update_test.go

    	if err := DB.Model(&results[1]).Clauses(clause.Returning{Columns: []clause.Column{{Name: "age"}}}).Updates(map[string]interface{}{"age": gorm.Expr("age + ?", 100)}).Error; err != nil {
    		t.Errorf("Not error should happen when updating with gorm expr, but got %v", err)
    	}
    
    	if results[1].Age-results[0].Age != 100 {
    		t.Errorf("failed to return updated age column")
    	}
    }
    
    func TestUpdateWithDiffSchema(t *testing.T) {
    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)
  4. tests/scanner_valuer_test.go

    	}
    
    	AssertObjEqual(t, result, data, "Name", "Gender", "Age")
    
    	if err := DB.Where(data).Assign(ScannerValuerStruct{Age: sql.NullInt64{Int64: 18, Valid: true}}).FirstOrCreate(&result).Error; err != nil {
    		t.Errorf("Should not raise any error, but got %v", err)
    	}
    
    	if result.Age.Int64 != 18 {
    		t.Errorf("should update age to 18")
    	}
    
    	var result2 ScannerValuerStruct
    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)
  5. schema/index_test.go

    	Name4        string `gorm:"uniqueIndex"`
    	Name5        int64  `gorm:"index:,class:FULLTEXT,comment:hello \\, world,where:age > 10"`
    	Name6        int64  `gorm:"index:profile,comment:hello \\, world,where:age > 10"`
    	Age          int64  `gorm:"index:profile,expression:ABS(age),option:WITH PARSER parser_name"`
    	OID          int64  `gorm:"index:idx_id;index:idx_oid,unique"`
    	MemberNumber string `gorm:"index:idx_id,priority:1"`
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sun Feb 04 07:49:19 GMT 2024
    - 8K bytes
    - Viewed (0)
  6. tests/helper_test.go

    		} else {
    			AssertObjEqual(t, newUser, user, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "Age", "Birthday",
    				"CompanyID", "ManagerID", "Active")
    		}
    	}
    
    	AssertObjEqual(t, user, expect, "ID", "CreatedAt", "UpdatedAt", "DeletedAt", "Name", "Age", "Birthday", "CompanyID",
    		"ManagerID", "Active")
    
    	t.Run("Account", func(t *testing.T) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  7. tests/upsert_test.go

    	}
    
    	DB.Where(&User{Name: "find or init"}).Assign("age", 44).FirstOrInit(&user4)
    	if user4.Name != "find or init" || user4.ID != 0 || user4.Age != 44 {
    		t.Errorf("user should be initialized with search value and assign attrs")
    	}
    
    	DB.Save(&User{Name: "find or init", Age: 33})
    	DB.Where(&User{Name: "find or init"}).Attrs("age", 44).FirstOrInit(&user5)
    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)
  8. tests/distinct_test.go

    	var results []User
    	if err := DB.Distinct("name", "age").Where("name like ?", "distinct%").Order("name, age desc").Find(&results).Error; err != nil {
    		t.Errorf("failed to query users, got error: %v", err)
    	}
    
    	expects := []User{
    		{Name: "distinct", Age: 20},
    		{Name: "distinct", Age: 18},
    		{Name: "distinct-2", Age: 18},
    		{Name: "distinct-3", Age: 18},
    	}
    
    	if len(results) != 4 {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Jan 06 07:02:53 GMT 2022
    - 2.5K bytes
    - Viewed (0)
  9. chainable_api.go

    // Select accepts both string arguments and arrays.
    //
    //	// Select name and age of user using multiple arguments
    //	db.Select("name", "age").Find(&users)
    //	// Select name and age of user using an array
    //	db.Select([]string{"name", "age"}).Find(&users)
    func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) {
    	tx = db.getInstance()
    
    	switch v := query.(type) {
    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)
  10. 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",
    			Email: "email",
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Mar 18 05:48:42 GMT 2024
    - 1.4K bytes
    - Viewed (0)
Back to top