Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 19 of 19 for many2many (0.3 sec)

  1. callbacks/delete.go

    						withoutConditions = true
    						break
    					}
    				}
    
    				if !withoutConditions && db.AddError(tx.Clauses(clause.Where{Exprs: queryConds}).Delete(modelValue).Error) != nil {
    					return
    				}
    			case schema.Many2Many:
    				var (
    					queryConds     = make([]clause.Expression, 0, len(rel.References))
    					foreignFields  = make([]*schema.Field, 0, len(rel.References))
    					relForeignKeys = make([]string, 0, len(rel.References))
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Feb 25 02:48:23 GMT 2022
    - 5.6K bytes
    - Viewed (0)
  2. callbacks/associations.go

    					}
    
    					saveAssociations(db, rel, elems, selectColumns, restricted, assignmentColumns)
    				}
    			}
    
    			// Save Many2Many associations
    			for _, rel := range db.Statement.Schema.Relationships.Many2Many {
    				if v, ok := selectColumns[rel.Name]; (ok && !v) || (!ok && restricted) {
    					continue
    				}
    
    				fieldType := rel.Field.IndirectFieldType.Elem()
    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)
  3. tests/embedded_struct_test.go

    		t.Errorf("Failed to create got error %v", err)
    	}
    }
    
    func TestEmbeddedRelations(t *testing.T) {
    	type EmbUser struct {
    		gorm.Model
    		Name      string
    		Age       uint
    		Languages []Language `gorm:"many2many:EmbUserSpeak;"`
    	}
    
    	type AdvancedUser struct {
    		EmbUser  `gorm:"embedded"`
    		Advanced bool
    	}
    
    	DB.Migrator().DropTable(&AdvancedUser{})
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Oct 26 03:58:13 GMT 2023
    - 7.3K bytes
    - Viewed (0)
  4. callbacks/preload.go

    	fieldValues := make([]interface{}, len(relForeignFields))
    
    	// clean up old values before preloading
    	switch reflectValue.Kind() {
    	case reflect.Struct:
    		switch rel.Type {
    		case schema.HasMany, schema.Many2Many:
    			tx.AddError(rel.Field.Set(tx.Statement.Context, reflectValue, reflect.MakeSlice(rel.Field.IndirectFieldType, 0, 10).Interface()))
    		default:
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  5. tests/joins_table_test.go

    package tests_test
    
    import (
    	"testing"
    	"time"
    
    	"gorm.io/gorm"
    	"gorm.io/gorm/clause"
    )
    
    type Person struct {
    	ID        int
    	Name      string
    	Addresses []Address `gorm:"many2many:person_addresses;"`
    	DeletedAt gorm.DeletedAt
    }
    
    type Address struct {
    	ID   uint
    	Name string
    }
    
    type PersonAddress struct {
    	PersonID  int
    	AddressID int
    	CreatedAt time.Time
    	DeletedAt gorm.DeletedAt
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Thu Sep 10 13:46:18 GMT 2020
    - 3.5K bytes
    - Viewed (0)
  6. schema/schema_test.go

    		},
    		{
    			Name: "Team", Type: schema.HasMany, Schema: "User", FieldSchema: "User",
    			References: []Reference{{"ID", "User", "ManagerID", "User", "", true}},
    		},
    		{
    			Name: "Languages", Type: schema.Many2Many, Schema: "User", FieldSchema: "Language",
    			JoinTable: JoinTable{Name: "UserSpeak", Table: "user_speaks", Fields: []schema.Field{
    				{
    					Name: "UserID", DBName: "user_id", BindNames: []string{"UserID"}, DataType: schema.Uint,
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 12.9K bytes
    - Viewed (0)
  7. tests/associations_test.go

    func TestAssociationEmptyQueryClause(t *testing.T) {
    	type Organization struct {
    		gorm.Model
    		Name string
    	}
    	type Region struct {
    		gorm.Model
    		Name          string
    		Organizations []Organization `gorm:"many2many:region_orgs;"`
    	}
    	type RegionOrg struct {
    		RegionId       uint
    		OrganizationId uint
    		Empty          myType
    	}
    	if err := DB.SetupJoinTable(&Region{}, "Organizations", &RegionOrg{}); err != nil {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Feb 08 08:29:09 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  8. migrator/migrator.go

    		return &uni, stmt.Table
    	}
    
    	getTable := func(rel *schema.Relationship) string {
    		switch rel.Type {
    		case schema.HasOne, schema.HasMany:
    			return rel.FieldSchema.Table
    		case schema.Many2Many:
    			return rel.JoinTable.Table
    		}
    		return stmt.Table
    	}
    
    	for _, rel := range stmt.Schema.Relationships.Relations {
    		if constraint := rel.ParseConstraint(); constraint != nil && constraint.Name == name {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  9. tests/migrate_test.go

    		{"accounts", "fk_users_account"},
    		{"users", "fk_users_team"},
    		{"users", "fk_users_company"},
    	} {
    		if !DB.Migrator().HasConstraint(indexes[0], indexes[1]) {
    			t.Fatalf("Failed to find index for many2many for %v %v", indexes[0], indexes[1])
    		}
    	}
    }
    
    func TestAutoMigrateInt8PG(t *testing.T) {
    	if DB.Dialector.Name() != "postgres" {
    		return
    	}
    
    	type Smallint int8
    
    	type MigrateInt struct {
    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