Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for Many2Many (0.07 sec)

  1. tests/associations_many2many_test.go

    	}
    
    	// Append
    	languages1 := []Language{
    		{Code: "language-many2many-append-1", Name: "language-many2many-append-1"},
    	}
    	languages2 := []Language{}
    	languages3 := []Language{
    		{Code: "language-many2many-append-3-1", Name: "language-many2many-append-3-1"},
    		{Code: "language-many2many-append-3-2", Name: "language-many2many-append-3-2"},
    	}
    	DB.Create(&languages1)
    	DB.Create(&languages3)
    
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Sat Jun 10 13:05:19 UTC 2023
    - 13.2K bytes
    - Viewed (0)
  2. schema/relationship.go

    		schema.err = err
    		return nil
    	}
    
    	if hasPolymorphicRelation(field.TagSettings) {
    		schema.buildPolymorphicRelation(relation, field)
    	} else if many2many := field.TagSettings["MANY2MANY"]; many2many != "" {
    		schema.buildMany2ManyRelation(relation, field, many2many)
    	} else if belongsTo := field.TagSettings["BELONGSTO"]; belongsTo != "" {
    		schema.guessRelation(relation, field, guessBelongs)
    	} else {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 03:46:59 UTC 2024
    - 22.7K bytes
    - Viewed (0)
  3. schema/relationship_test.go

    		Name: "Profiles", Type: schema.Many2Many, Schema: "User", FieldSchema: "Profile",
    		JoinTable: JoinTable{Name: "user_profiles", Table: "user_profiles"},
    		References: []Reference{
    			{"Refer", "User", "UserReferID", "user_profiles", "", true},
    			{"UserRefer", "Profile", "ProfileRefer", "user_profiles", "", false},
    		},
    	}, Relation{
    		Name: "Profiles2", Type: schema.Many2Many, Schema: "User", FieldSchema: "Profile",
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Mon Apr 15 03:20:20 UTC 2024
    - 25.5K bytes
    - Viewed (0)
  4. association.go

    				} else {
    					association.Error = tx.Where(clause.IN{Column: column, Values: values}).UpdateColumns(updateMap).Error
    				}
    			}
    		case schema.Many2Many:
    			var (
    				primaryFields, relPrimaryFields     []*schema.Field
    				joinPrimaryKeys, joinRelPrimaryKeys []string
    				modelValue                          = reflect.New(rel.JoinTable.ModelType).Interface()
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:49:45 UTC 2024
    - 21.5K bytes
    - Viewed (0)
  5. 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:
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Jun 12 10:52:33 UTC 2024
    - 11.6K bytes
    - Viewed (0)
  6. tests/multi_primary_keys_test.go

    		t.Fatalf("Should find 3 tags")
    	}
    
    	var blog1 Blog
    	DB.Preload("Tags").Find(&blog1)
    	if !compareTags(blog1.Tags, []string{"tag1", "tag2", "tag3"}) {
    		t.Fatalf("Preload many2many relations")
    	}
    
    	// Replace
    	tag5 := &Tag{Locale: "ZH", Value: "tag5"}
    	tag6 := &Tag{Locale: "ZH", Value: "tag6"}
    	DB.Model(&blog).Association("Tags").Replace(tag5, tag6)
    	var tags2 []Tag
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Jan 06 07:02:53 UTC 2022
    - 12.8K bytes
    - Viewed (0)
  7. 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{
    				{
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Thu Jun 20 12:19:31 UTC 2024
    - 13.3K bytes
    - Viewed (0)
  8. 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()
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Tue Apr 11 03:06:13 UTC 2023
    - 14.3K bytes
    - Viewed (0)
  9. 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 {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Apr 26 07:15:49 UTC 2024
    - 29K bytes
    - Viewed (0)
Back to top