Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 23 for id (0.24 sec)

  1. tests/joins_test.go

    	if db5.Error != nil {
    		t.Errorf("Should not raise error for join where identical fields in different tables. Error: %s", db5.Error.Error())
    	}
    
    	var users6 []User
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 26 14:19:32 GMT 2023
    - 13.5K bytes
    - Viewed (1)
  2. tests/create_test.go

    	}
    
    	if _, ok := record["@id"]; ok && fmt.Sprint(res["id"]) != fmt.Sprint(record["@id"]) {
    		t.Fatalf("failed to create data from map with table, @id != id, got %v, expect %v", res["id"], record["@id"])
    	}
    
    	// case 2: create from *map[string]interface{}
    	record1 := map[string]interface{}{"name": "create_from_map_with_table_1", "age": 18}
    	tableDB2 := DB.Table("users")
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 26.4K bytes
    - Viewed (0)
  3. schema/relationship_test.go

    		LocaleTags []Tag `gorm:"many2many:locale_blog_tags;ForeignKey:id,locale;References:id"`
    	}
    
    	checkStructRelation(t, &Blog{},
    		Relation{
    			Name: "Tags", Type: schema.Many2Many, Schema: "Blog", FieldSchema: "Tag",
    			JoinTable: JoinTable{Name: "blog_tags", Table: "blog_tags"},
    			References: []Reference{
    				{"ID", "Blog", "BlogID", "blog_tags", "", true},
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  4. tests/associations_has_many_test.go

    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	CheckUser(t, user, user)
    
    	// Find
    	var user2 User
    	DB.Find(&user2, "id = ?", user.ID)
    	DB.Model(&user2).Association("Pets").Find(&user2.Pets)
    	CheckUser(t, user2, user)
    
    	var pets []Pet
    	DB.Model(&user).Where("name = ?", user.Pets[0].Name).Association("Pets").Find(&pets)
    
    	if len(pets) != 1 {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:36:08 GMT 2023
    - 15.6K bytes
    - Viewed (0)
  5. tests/upsert_test.go

    	}
    
    	if user1.Name != "find or create" || user1.ID == 0 || user1.Age != 33 {
    		t.Errorf("user should be created with search value")
    	}
    
    	DB.Where(&User{Name: "find or create", Age: 33}).FirstOrCreate(&user2)
    	if user1.ID != user2.ID || user2.Name != "find or create" || user2.ID == 0 || user2.Age != 33 {
    		t.Errorf("user should be created with search value")
    	}
    
    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)
  6. tests/preload_suits_test.go

    	type (
    		Level0 struct {
    			ID       uint
    			Value    string
    			Level1ID uint
    		}
    		Level1 struct {
    			ID         uint
    			Value      string
    			Level2ID   *uint
    			Level2_1ID *uint
    			Level0s    []Level0 `json:",omitempty"`
    		}
    		Level2 struct {
    			ID       uint
    			Level1s  []Level1
    			Level3ID uint
    		}
    		Level2_1 struct {
    			ID       uint
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Mar 18 05:38:46 GMT 2022
    - 30.3K bytes
    - Viewed (0)
  7. tests/hooks_test.go

    	DB.Model(&Product5{}).Create(&p)
    
    	err := DB.Model(&Product5{}).Where("id", p.ID).Update("name", "update_name_1").Error
    	if err != nil {
    		t.Fatalf("should update success, but got err %v", err)
    	}
    	if beforeUpdateCall != 1 {
    		t.Fatalf("before update should be called")
    	}
    
    	err = DB.Model(Product5{}).Where("id", p.ID).Update("name", "update_name_2").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)
  8. chainable_api.go

    	}
    	return
    }
    
    // Joins specify Joins conditions
    //
    //	db.Joins("Account").Find(&user)
    //	db.Joins("JOIN emails ON emails.user_id = users.id AND emails.email = ?", "******@****.***").Find(&user)
    //	db.Joins("Account", DB.Select("id").Where("user_id = users.id AND name = ?", "someName").Model(&Account{}))
    func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
    	return joins(db, clause.LeftJoin, query, args...)
    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)
  9. tests/table_test.go

    }
    
    func TestTableWithAllFields(t *testing.T) {
    	dryDB := DB.Session(&gorm.Session{DryRun: true, QueryFields: true})
    	userQuery := "SELECT .*user.*id.*user.*created_at.*user.*updated_at.*user.*deleted_at.*user.*name.*user.*age" +
    		".*user.*birthday.*user.*company_id.*user.*manager_id.*user.*active.* "
    
    	r := dryDB.Table("`user`").Find(&User{}).Statement
    	if !regexp.MustCompile(userQuery + "FROM `user`").MatchString(r.Statement.SQL.String()) {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Mar 09 09:31:28 GMT 2024
    - 10.6K bytes
    - Viewed (0)
  10. callbacks/create.go

    				return
    			}
    			pkField = db.Statement.Schema.PrioritizedPrimaryField
    			pkFieldName = db.Statement.Schema.PrioritizedPrimaryField.DBName
    		}
    
    		// append @id column with value for auto-increment primary key
    		// the @id value is correct, when: 1. without setting auto-increment primary key, 2. database AutoIncrementIncrement = 1
    		switch values := db.Statement.Dest.(type) {
    		case map[string]interface{}:
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 08 03:29:55 GMT 2024
    - 12.5K bytes
    - Viewed (0)
Back to top