Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 20 for and (0.24 sec)

  1. tests/sql_builder_test.go

    		t.Fatalf("invalid sql generated, got %v", sql)
    	}
    
    	sql = dryRunDB.Where("a = ? or b = ?", "a", "b").Where("c = ? and d = ?", "c", "d").Not("e = ? and f = ?", "e", "f").Find(&User{}).Statement.SQL.String()
    	if !regexp.MustCompile(`WHERE \(a = .+ or b = .+\) AND \(c = .+ and d = .+\) AND NOT \(e = .+ and f = .+\) AND .users.\..deleted_at. IS NULL`).MatchString(sql) {
    		t.Fatalf("invalid sql generated, got %v", sql)
    	}
    
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 16.7K bytes
    - Viewed (0)
  2. tests/upsert_test.go

    		t.Errorf("user should be initialized with search value and attrs")
    	}
    
    	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})
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Mon Sep 05 07:39:19 UTC 2022
    - 11.4K bytes
    - Viewed (0)
  3. schema/relationship.go

    		}
    	}
    
    	return relation
    }
    
    // hasPolymorphicRelation check if has polymorphic relation
    // 1. `POLYMORPHIC` tag
    // 2. `POLYMORPHICTYPE` and `POLYMORPHICID` tag
    func hasPolymorphicRelation(tagSettings map[string]string) bool {
    	if _, ok := tagSettings["POLYMORPHIC"]; ok {
    		return true
    	}
    
    	_, hasType := tagSettings["POLYMORPHICTYPE"]
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 03:46:59 UTC 2024
    - 22.7K bytes
    - Viewed (0)
  4. finisher_api.go

    // FirstOrInit finds the first matching record, otherwise if not found initializes a new instance with given conds.
    // Each conds must be a struct or map.
    //
    // FirstOrInit never modifies the database. It is often used with Assign and Attrs.
    //
    //	// assign an email if the record is not found
    //	db.Where(User{Name: "non_existing"}).Attrs(User{Email: "******@****.***"}).FirstOrInit(&user)
    //	// user -> User{Name: "non_existing", Email: "******@****.***"}
    //
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 22.7K bytes
    - Viewed (0)
  5. tests/joins_test.go

    	if len(users2) != 1 {
    		t.Errorf("should find one users using left join with conditions, but got %v", len(users2))
    	}
    
    	var users3 []User
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:52:33 UTC 2024
    - 15K bytes
    - Viewed (0)
  6. tests/preload_test.go

    	if len(user3.Pets) != 0 {
    		t.Fatalf("User.Pet[0] was deleted and should not exist.")
    	}
    
    	var user4 *User
    	DB.Preload("Pets.Toy").Find(&user4, "id = ?", user.ID)
    	if len(user4.Pets) != 0 {
    		t.Fatalf("User.Pet[0] was deleted and should not exist.")
    	}
    
    	var user5 User
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:00:47 UTC 2024
    - 15.9K bytes
    - Viewed (0)
  7. tests/associations_test.go

    		t.Errorf("Failed, got error: %v", err)
    	}
    
    	if DB.First(&Coupon{}, "id = ?", coupon.ID).Error != nil {
    		t.Errorf("Failed to query saved coupon")
    	}
    
    	if DB.First(&CouponProduct{}, "coupon_id = ? AND product_id = ?", coupon.ID, "full-save-association-product1").Error != nil {
    		t.Errorf("Failed to query saved association")
    	}
    
    	orders := []Order{{Num: "order1", Coupon: coupon}, {Num: "order2", Coupon: coupon}}
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Feb 08 08:29:09 UTC 2023
    - 10.9K bytes
    - Viewed (0)
  8. callbacks/preload.go

    	"reflect"
    	"sort"
    	"strings"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    )
    
    // parsePreloadMap extracts nested preloads. e.g.
    //
    //	// schema has a "k0" relation and a "k7.k8" embedded relation
    //	parsePreloadMap(schema, map[string][]interface{}{
    //		clause.Associations: {"arg1"},
    //		"k1":                {"arg2"},
    //		"k2.k3":             {"arg3"},
    //		"k4.k5.k6":          {"arg4"},
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:52:33 UTC 2024
    - 11.6K bytes
    - Viewed (0)
  9. schema/field.go

    	Set                    func(context.Context, reflect.Value, interface{}) error
    	Serializer             SerializerInterface
    	NewValuePool           FieldNewValuePool
    
    	// In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable.
    	// When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique.
    	// It causes field unnecessarily migration.
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Mon Apr 15 03:20:20 UTC 2024
    - 32K bytes
    - Viewed (0)
  10. tests/create_test.go

    	}
    
    	jt := JoinTable{UserID: 1, FriendID: 2}
    	err := DB.Create(&jt).Error
    	if err != nil {
    		t.Errorf("No error should happen when create a record without a GORM primary key. But in the database this primary key exists and is the union of 2 or more fields\n But got: %s", err)
    	}
    }
    
    func TestSelectWithCreate(t *testing.T) {
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Tue Mar 19 03:50:28 UTC 2024
    - 26.4K bytes
    - Viewed (0)
Back to top