Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 8 of 8 for manny (0.17 sec)

  1. schema/relationship.go

    const (
    	HasOne    RelationshipType = "has_one"      // HasOneRel has one relationship
    	HasMany   RelationshipType = "has_many"     // HasManyRel has many relationship
    	BelongsTo RelationshipType = "belongs_to"   // BelongsToRel belongs to relationship
    	Many2Many RelationshipType = "many_to_many" // Many2ManyRel many to many relationship
    	has       RelationshipType = "has"
    )
    
    type Relationships struct {
    	HasOne    []*Relationship
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 03:46:59 UTC 2024
    - 22.7K bytes
    - Viewed (0)
  2. tests/upsert_test.go

    	if err := DB.Where("name = ?", "first_or_create_pet1").First(&Pet{}).Error; err != nil {
    		t.Errorf("has many association should be saved")
    	}
    
    	if err := DB.Where("number = ?", "1231231231").First(&Account{}).Error; err != nil {
    		t.Errorf("belongs to association should be saved")
    	}
    }
    
    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. utils/tests/models.go

    import (
    	"database/sql"
    	"time"
    
    	"gorm.io/gorm"
    )
    
    // User has one `Account` (has one), many `Pets` (has many) and `Toys` (has many - polymorphic)
    // He works in a Company (belongs to), he has a Manager (belongs to - single-table), and also managed a Team (has many - single-table)
    // He speaks many languages (many to many) and has many friends (many to many - single-table)
    // His pet also has one Toy (has one - polymorphic)
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Fri Dec 15 08:36:08 UTC 2023
    - 2.1K bytes
    - Viewed (0)
  4. tests/update_has_many_test.go

    package tests_test
    
    import (
    	"testing"
    
    	"gorm.io/gorm"
    	. "gorm.io/gorm/utils/tests"
    )
    
    func TestUpdateHasManyAssociations(t *testing.T) {
    	user := *GetUser("update-has-many", Config{})
    
    	if err := DB.Create(&user).Error; err != nil {
    		t.Fatalf("errors happened when create: %v", err)
    	}
    
    	user.Pets = []*Pet{{Name: "pet1"}, {Name: "pet2"}}
    	if err := DB.Save(&user).Error; err != nil {
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Thu Jan 06 07:02:53 UTC 2022
    - 2K bytes
    - Viewed (0)
  5. tests/associations_has_many_test.go

    	user.Pets = append(user.Pets, &pet)
    	CheckUser(t, user2, user)
    
    	AssertAssociationCount(t, user, "Pets", 3, "AfterAppend")
    
    	pets2 := []Pet{{Name: "pet-has-many-append-1-1"}, {Name: "pet-has-many-append-1-1"}}
    
    	if err := DB.Model(&user2).Association("Pets").Append(&pets2); err != nil {
    		t.Fatalf("Error happened when append pet, got %v", err)
    	}
    
    	for _, pet := range pets2 {
    		pet := pet
    		if pet.ID == 0 {
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 16K bytes
    - Viewed (0)
  6. tests/associations_test.go

    	AssertEqual(t, err, gorm.ErrPrimaryKeyRequired)
    	// has many
    	err = DB.Model(&emptyUser).Association("Pets").Delete(&user1.Pets)
    	AssertEqual(t, err, gorm.ErrPrimaryKeyRequired)
    	// has one
    	err = DB.Model(&emptyUser).Association("Account").Delete(&user1.Account)
    	AssertEqual(t, err, gorm.ErrPrimaryKeyRequired)
    	// many to many
    	err = DB.Model(&emptyUser).Association("Languages").Delete(&user1.Languages)
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Wed Feb 08 08:29:09 UTC 2023
    - 10.9K bytes
    - Viewed (0)
  7. callbacks/associations.go

    							assignmentColumns = append(assignmentColumns, ref.ForeignKey.DBName)
    						}
    
    						saveAssociations(db, rel, f, selectColumns, restricted, assignmentColumns)
    					}
    				}
    			}
    
    			// Save Has Many associations
    			for _, rel := range db.Statement.Schema.Relationships.HasMany {
    				if v, ok := selectColumns[rel.Name]; (ok && !v) || (!ok && restricted) {
    					continue
    				}
    
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Tue Apr 11 03:06:13 UTC 2023
    - 14.3K bytes
    - Viewed (0)
  8. schema/relationship_test.go

    						References: []Reference{
    							{ForeignKey: "Type", ForeignSchema: "Toy", PrimaryValue: "users"},
    						},
    					},
    				},
    			},
    		})
    	})
    
    	t.Run("has many", func(t *testing.T) {
    		type Toy struct {
    			ID        int
    			Name      string
    			OwnerID   int
    			OwnerType string
    		}
    
    		type Cat struct {
    			ID   int
    			Name string
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Mon Apr 15 03:20:20 UTC 2024
    - 25.5K bytes
    - Viewed (0)
Back to top