Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 17 for relationship (0.26 sec)

  1. schema/relationship.go

    	has       RelationshipType = "has"
    )
    
    type Relationships struct {
    	HasOne    []*Relationship
    	BelongsTo []*Relationship
    	HasMany   []*Relationship
    	Many2Many []*Relationship
    	Relations map[string]*Relationship
    
    	EmbeddedRelations map[string]*Relationships
    }
    
    type Relationship struct {
    	Name                     string
    	Type                     RelationshipType
    	Field                    *Field
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
  2. schema/relationship_test.go

    	if err != nil {
    		t.Fatalf("failed to parse schema, got error %v", err)
    	}
    
    	if len(userSchema.Relationships.Relations) != 1 {
    		t.Fatalf("expects 1 relations, but got %v", len(userSchema.Relationships.Relations))
    	}
    
    	if createdByRel, ok := userSchema.Relationships.Relations["CreatedBy"]; ok {
    		if createdByRel.FieldSchema != userSchema {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  3. association.go

    					if err := association.Relationship.Field.Set(association.DB.Statement.Context, reflectValue.Index(i), reflect.New(association.Relationship.Field.IndirectFieldType).Interface()); err != nil {
    						association.Error = err
    						break
    					}
    
    					if association.Relationship.JoinTable == nil {
    						for _, ref := range association.Relationship.References {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu May 04 11:30:45 GMT 2023
    - 21.2K bytes
    - Viewed (0)
  4. callbacks/preload.go

    	return names
    }
    
    // preloadEntryPoint enters layer by layer. It will call real preload if it finds the right entry point.
    // If the current relationship is embedded or joined, current query will be ignored.
    //
    //nolint:cyclop
    func preloadEntryPoint(db *gorm.DB, joins []string, relationships *schema.Relationships, preloads map[string][]interface{}, associationsConds []interface{}) error {
    	preloadMap := parsePreloadMap(db.Statement.Schema, preloads)
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Thu Apr 25 12:21:03 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  5. callbacks/query.go

    			for _, join := range db.Statement.Joins {
    				if db.Statement.Schema != nil {
    					var isRelations bool // is relations or raw sql
    					var relations []*schema.Relationship
    					relation, ok := db.Statement.Schema.Relationships.Relations[join.Name]
    					if ok {
    						isRelations = true
    						relations = append(relations, relation)
    					} else {
    						// handle nested join like "Manager.Company"
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Jan 29 03:34:57 GMT 2024
    - 9.9K bytes
    - Viewed (0)
  6. schema/schema.go

    		ModelType:        modelType,
    		Table:            tableName,
    		FieldsByName:     map[string]*Field{},
    		FieldsByBindName: map[string]*Field{},
    		FieldsByDBName:   map[string]*Field{},
    		Relationships:    Relationships{Relations: map[string]*Relationship{}},
    		cacheStore:       cacheStore,
    		namer:            namer,
    		initialized:      make(chan struct{}),
    	}
    	// When the schema initialization is completed, the channel will be closed
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Tue Oct 10 06:50:29 GMT 2023
    - 13.7K bytes
    - Viewed (0)
  7. schema/utils.go

    	}
    	return reflect.StructTag(fmt.Sprintf(`gorm:"%s;%s"`, value, t))
    }
    
    // GetRelationsValues get relations's values from a reflect value
    func GetRelationsValues(ctx context.Context, reflectValue reflect.Value, rels []*Relationship) (reflectResults reflect.Value) {
    	for _, rel := range rels {
    		reflectResults = reflect.MakeSlice(reflect.SliceOf(reflect.PtrTo(rel.FieldSchema.ModelType)), 0, 1)
    
    		appendToResults := func(value reflect.Value) {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Sat Aug 19 13:35:14 GMT 2023
    - 5.5K bytes
    - Viewed (0)
  8. schema/naming.go

    // Namer namer interface
    type Namer interface {
    	TableName(table string) string
    	SchemaName(table string) string
    	ColumnName(table, column string) string
    	JoinTableName(joinTable string) string
    	RelationshipFKName(Relationship) string
    	CheckerName(table, column string) string
    	IndexName(table, column string) string
    	UniqueName(table, column string) string
    }
    
    // Replacer replacer interface like strings.Replacer
    type Replacer interface {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Mon Oct 30 09:15:49 GMT 2023
    - 5.2K bytes
    - Viewed (0)
  9. schema/schema_helper_test.go

    				if r, ok := rs.Relations[n]; !ok {
    					t.Errorf("failed to find relation by name %s", n)
    				} else {
    					checkSchemaRelation(t, &schema.Schema{
    						Relationships: schema.Relationships{
    							Relations: map[string]*schema.Relationship{n: rel},
    						},
    					}, r)
    				}
    			}
    			checkEmbeddedRelations(t, relations.EmbeddedRelations, rs.EmbeddedRelations)
    		})
    	}
    }
    
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Dec 15 08:31:23 GMT 2023
    - 7.5K bytes
    - Viewed (0)
  10. 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 {
    Go
    - Registered: Sun Apr 28 09:35:09 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
Back to top