Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for Pet (0.15 sec)

  1. tests/helper_test.go

    	}
    
    	if config.NamedPet {
    		user.NamedPet = &Pet{Name: name + "_namepet"}
    	}
    
    	return &user
    }
    
    func CheckPetUnscoped(t *testing.T, pet Pet, expect Pet) {
    	doCheckPet(t, pet, expect, true)
    }
    
    func CheckPet(t *testing.T, pet Pet, expect Pet) {
    	doCheckPet(t, pet, expect, false)
    }
    
    func doCheckPet(t *testing.T, pet Pet, expect Pet, unscoped bool) {
    	if pet.ID != 0 {
    		var newPet Pet
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Tue Mar 19 03:50:28 GMT 2024
    - 8K bytes
    - Viewed (0)
  2. tests/preload_test.go

    	for idx, user := range users2[0:2] {
    		for _, pet := range user.Pets {
    			if pet.Toy.Name != "" {
    				t.Errorf("No toy should for user %v's pet %v but got %v", idx+1, pet.Name, pet.Toy.Name)
    			}
    		}
    	}
    
    	if len(users2[2].Pets) != 3 {
    		t.Errorf("Invalid pet toys found for user 3 got %v", len(users2[2].Pets))
    	} else {
    		sort.Slice(users2[2].Pets, func(i, j int) bool {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 14.9K bytes
    - Viewed (0)
  3. tests/test_jsonable_encoder.py

        person = Person(name="Foo")
        pet = Pet(owner=person, name="Firulais")
        assert jsonable_encoder(pet) == {"name": "Firulais", "owner": {"name": "Foo"}}
        assert jsonable_encoder(pet, include={"name"}) == {"name": "Firulais"}
        assert jsonable_encoder(pet, exclude={"owner"}) == {"name": "Firulais"}
        assert jsonable_encoder(pet, include={}) == {}
        assert jsonable_encoder(pet, exclude={}) == {
            "name": "Firulais",
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 9K bytes
    - Viewed (0)
  4. tests/create_test.go

    	t.Run("Struct", func(t *testing.T) {
    		pet := Pet{
    			Name: "PolymorphicHasOne",
    			Toy:  Toy{Name: "Toy-PolymorphicHasOne"},
    		}
    
    		if err := DB.Create(&pet).Error; err != nil {
    			t.Fatalf("errors happened when create: %v", err)
    		}
    
    		CheckPet(t, pet, pet)
    
    		var pet2 Pet
    		DB.Preload("Toy").Find(&pet2, "id = ?", pet.ID)
    		CheckPet(t, pet2, pet)
    	})
    
    	t.Run("Slice", func(t *testing.T) {
    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)
  5. tests/table_test.go

    		t.Errorf("Table with escape character, got %v", r.Statement.SQL.String())
    	}
    
    	r = dryDB.Table("(?) as u, (?) as p", DB.Model(&User{}).Select("name"), DB.Model(&Pet{}).Select("name")).Find(&User{}).Statement
    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)
  6. schema/relationship.go

    			}
    			relationships.Relations[relation.Name] = relation
    		}
    	}
    }
    
    // User has many Toys, its `Polymorphic` is `Owner`, Pet has one Toy, its `Polymorphic` is `Owner`
    //
    //	type User struct {
    //	  Toys []Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Pet struct {
    //	  Toy Toy `gorm:"polymorphic:Owner;"`
    //	}
    //	type Toy struct {
    //	  OwnerID   int
    //	  OwnerType string
    //	}
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  7. docs/en/docs/tutorial/sql-databases.md

    So, `orion_cat.owner.name` could be the name (from the `name` column in the `owners` table) of this pet's owner.
    
    It could have a value like `"Arquilian"`.
    
    And the ORM will do all the work to get the information from the corresponding table *owners* when you try to access it from your pet object.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 29.6K bytes
    - Viewed (0)
  8. docs/zh/docs/tutorial/sql-databases.md

    **FastAPI**可与任何数据库在任何样式的库中一起与 数据库进行通信。
    
    一种常见的模式是使用“ORM”:对象关系映射。
    
    ORM 具有在代码和数据库表(“*关系型”)中的**对象**之间转换(“*映射*”)的工具。
    
    使用 ORM,您通常会在 SQL 数据库中创建一个代表映射的类,该类的每个属性代表一个列,具有名称和类型。
    
    例如,一个类`Pet`可以表示一个 SQL 表`pets`。
    
    该类的每个*实例对象都代表数据库中的一行数据。*
    
    又例如,一个对象`orion_cat`(`Pet`的一个实例)可以有一个属性`orion_cat.type`, 对标数据库中的`type`列。并且该属性的值可以是其它,例如`"cat"`。
    
    这些 ORM 还具有在表或实体之间建立关系的工具(比如创建多表关系)。
    
    这样,您还可以拥有一个属性`orion_cat.owner`,它包含该宠物所有者的数据,这些数据取自另外一个表。
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 27K bytes
    - Viewed (0)
  9. docs/em/docs/tutorial/sql-databases.md

    ⚠ ⚓ ⚙️ "🐜": "🎚-🔗 🗺" 🗃.
    
    🐜 ✔️ 🧰 🗜 ("*🗺*") 🖖 *🎚* 📟 & 💽 🏓 ("*🔗*").
    
    ⏮️ 🐜, 👆 🛎 ✍ 🎓 👈 🎨 🏓 🗄 💽, 🔠 🔢 🎓 🎨 🏓, ⏮️ 📛 & 🆎.
    
    🖼 🎓 `Pet` 💪 🎨 🗄 🏓 `pets`.
    
    & 🔠 *👐* 🎚 👈 🎓 🎨 ⏭ 💽.
    
    🖼 🎚 `orion_cat` (👐 `Pet`) 💪 ✔️ 🔢 `orion_cat.type`, 🏓 `type`. & 💲 👈 🔢 💪, ✅ `"cat"`.
    
    👫 🐜 ✔️ 🧰 ⚒ 🔗 ⚖️ 🔗 🖖 🏓 ⚖️ 👨‍💼.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 25.2K bytes
    - Viewed (1)
  10. tests/migrate_test.go

    	"gorm.io/gorm/logger"
    	"gorm.io/gorm/migrator"
    	"gorm.io/gorm/schema"
    	"gorm.io/gorm/utils"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestMigrate(t *testing.T) {
    	allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}, &Tools{}}
    	rand.Seed(time.Now().UnixNano())
    	rand.Shuffle(len(allModels), func(i, j int) { allModels[i], allModels[j] = allModels[j], allModels[i] })
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Mar 18 11:24:16 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top