Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for item1 (0.14 sec)

  1. tests/associations_has_many_test.go

    		LanguageCode string `gorm:"not null;type:varchar(2)"`
    	}
    	type Item struct {
    		gorm.Model
    		Logo     string        `gorm:"not null;type:varchar(50)"`
    		Contents []ItemContent `gorm:"foreignKey:ItemID"`
    	}
    
    	tx := DB.Session(&gorm.Session{})
    	tx.Migrator().DropTable(&ItemContent{}, &Item{})
    	tx.AutoMigrate(&ItemContent{}, &Item{})
    
    	item := Item{
    		Logo: "logo",
    		Contents: []ItemContent{
    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)
  2. tests/hooks_test.go

    	var productWithItem Product4
    	if err := DB.Session(&gorm.Session{SkipHooks: true}).Preload("Item").First(&productWithItem, "name = ?", product.Name).Error; err != nil {
    		t.Errorf("should find product, but got error %v", err)
    	}
    
    	if productWithItem.Item.AfterFindCallTimes != 0 {
    		t.Fatalf("AfterFind should not be called times:%d", productWithItem.Item.AfterFindCallTimes)
    	}
    }
    
    type Product5 struct {
    	gorm.Model
    	Name string
    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)
  3. callbacks/associations.go

    	}
    
    	return db.AddError(tx.Create(values).Error)
    }
    
    // check association values has been saved
    // if values kind is Struct, check it has been saved
    // if values kind is Slice/Array, check all items have been saved
    var visitMapStoreKey = "gorm:saved_association_map"
    
    func checkAssociationsSaved(db *gorm.DB, values reflect.Value) bool {
    	if visit, ok := db.Get(visitMapStoreKey); ok {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Apr 11 03:06:13 GMT 2023
    - 14.3K bytes
    - Viewed (0)
  4. tests/preload_suits_test.go

    	}
    
    	var got []Level1
    	if err := DB.Preload("Level2").Preload("Level2.Level3").Find(&got).Error; err != nil {
    		t.Error(err)
    	}
    
    	if len(got) != 2 {
    		t.Errorf("got %v items, expected 2", len(got))
    	}
    
    	if !reflect.DeepEqual(got[0], want) && !reflect.DeepEqual(got[1], want) {
    		t.Fatalf("got %s; want array containing %s", toJSONString(got), toJSONString(want))
    	}
    
    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)
  5. tests/query_test.go

    		Number3: 300.1,
    		Now:     &now,
    		Item1: &QueryResetItem{
    			ID:   "u_1_1",
    			Name: "item_1_1",
    		},
    		Item2: &QueryResetItem{
    			ID:   "u_1_2",
    			Name: "item_1_2",
    		},
    	}
    
    	q2 := QueryResetNullValue{
    		Item1: &QueryResetItem{
    			ID:   "u_2_1",
    			Name: "item_2_1",
    		},
    		Item2: &QueryResetItem{
    			ID:   "u_2_2",
    			Name: "item_2_2",
    		},
    	}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:22:53 GMT 2024
    - 49.8K bytes
    - Viewed (0)
  6. tests/associations_belongs_to_test.go

    	tx.AutoMigrate(&ItemParent{}, &ItemChild{})
    
    	item := ItemChild{
    		Name: "name",
    		ItemParent: ItemParent{
    			Logo: "logo",
    		},
    	}
    	if err := tx.Create(&item).Error; err != nil {
    		t.Fatalf("failed to create items, got error: %v", err)
    	}
    
    	// test replace
    	if err := tx.Model(&item).Association("ItemParent").Unscoped().Replace(&ItemParent{
    		Logo: "updated logo",
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 9.3K bytes
    - Viewed (0)
Back to top