Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 72 for hasone (0.05 sec)

  1. schema/relationship_test.go

    		UserRefer uint
    	}
    
    	type User struct {
    		gorm.Model
    		Profile Profile `gorm:"ForeignKey:UserRefer"`
    	}
    
    	checkStructRelation(t, &User{}, Relation{
    		Name: "Profile", Type: schema.HasOne, Schema: "User", FieldSchema: "Profile",
    		References: []Reference{{"ID", "User", "UserRefer", "Profile", "", true}},
    	})
    }
    
    func TestHasOneOverrideReferences(t *testing.T) {
    	type Profile struct {
    		gorm.Model
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Mon Aug 18 11:44:52 UTC 2025
    - 26.5K bytes
    - Viewed (0)
  2. schema/relationship.go

    		}
    
    		switch field.IndirectFieldType.Kind() {
    		case reflect.Struct:
    			relation.Type = HasOne
    		case reflect.Slice:
    			relation.Type = HasMany
    		}
    	}
    
    	if schema.err == nil {
    		schema.setRelation(relation)
    		switch relation.Type {
    		case HasOne:
    			schema.Relationships.HasOne = append(schema.Relationships.HasOne, relation)
    		case HasMany:
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Sun Nov 16 04:11:05 UTC 2025
    - 23.1K bytes
    - Viewed (1)
  3. association.go

    }
    
    func (association *Association) Append(values ...interface{}) error {
    	values = expandValues(values)
    
    	if association.Error == nil {
    		switch association.Relationship.Type {
    		case schema.HasOne, schema.BelongsTo:
    			if len(values) > 0 {
    				association.Error = association.Replace(values...)
    			}
    		default:
    			association.saveAssociation( /*clear*/ false, values...)
    		}
    	}
    
    	return association.Error
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Sun Oct 26 12:09:12 UTC 2025
    - 23.6K bytes
    - Viewed (0)
  4. schema/schema_test.go

    			f.Creatable = true
    			f.Updatable = true
    			f.Readable = true
    		})
    	}
    
    	// check relations
    	relations := []Relation{
    		{
    			Name: "Account", Type: schema.HasOne, Schema: "User", FieldSchema: "Account",
    			References: []Reference{{"ID", "User", "UserID", "Account", "", true}},
    		},
    		{
    			Name: "Pets", Type: schema.HasMany, Schema: "User", FieldSchema: "Pet",
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Thu Aug 28 02:57:17 UTC 2025
    - 13.3K bytes
    - Viewed (0)
  5. callbacks/associations.go

    		if db.Error == nil && db.Statement.Schema != nil {
    			selectColumns, restricted := db.Statement.SelectAndOmitColumns(create, !create)
    
    			// Save Has One associations
    			for _, rel := range db.Statement.Schema.Relationships.HasOne {
    				if v, ok := selectColumns[rel.Name]; (ok && !v) || (!ok && restricted) {
    					continue
    				}
    
    				switch db.Statement.ReflectValue.Kind() {
    				case reflect.Slice, reflect.Array:
    					var (
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Thu Feb 13 06:16:26 UTC 2025
    - 14.4K bytes
    - Viewed (0)
  6. migrator/migrator.go

    	if uni, ok := uniqueConstraints[name]; ok {
    		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 {
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Sun Oct 26 12:31:09 UTC 2025
    - 29.7K bytes
    - Viewed (0)
  7. tests/association_generics_test.go

    	}
    	if got.Age != 30 {
    		t.Fatalf("expected age 30, got %d", got.Age)
    	}
    	if len(got.Pets) != 1 || got.Pets[0].Name != "mix-pet" {
    		t.Fatalf("expected pet created, got %+v", got.Pets)
    	}
    }
    
    // HasOne unlink clears NamedPet
    func TestClauseAssociationSetUpdateHasOneUnlink(t *testing.T) {
    	ctx := context.Background()
    	user := User{Name: "TestClauseAssociationSetUpdateHasOneUnlink", Age: 25}
    	user.NamedPet = &Pet{Name: "np"}
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Fri Sep 12 05:42:26 UTC 2025
    - 37.9K bytes
    - Viewed (0)
  8. generics.go

    		}
    	}
    
    	assocDB := s.c.g.db.Session(&Session{NewDB: true, Context: ctx}).Model(assocModel).Where(op.Conditions)
    
    	switch rel.Type {
    	case schema.HasOne, schema.HasMany:
    		assocDB = assocDB.Where("? IN (?)", foreignColumns, base.Select(ownerPKNames))
    		switch op.Type {
    		case clause.OpUnlink:
    			return assocDB.Updates(fkNil).Error
    		case clause.OpDelete:
    Registered: Sun Dec 28 09:35:17 UTC 2025
    - Last Modified: Sun Nov 02 14:09:18 UTC 2025
    - 25.9K bytes
    - Viewed (0)
  9. android/guava-tests/test/com/google/common/collect/MapMakerInternalMapTest.java

          Segment<Object, Object, ?, ?> segment = map.segments[0];
    
          Object keyOne = new Object();
          Object valueOne = new Object();
          int hashOne = map.hash(keyOne);
          InternalEntry<Object, Object, ?> entryOne = segment.newEntryForTesting(keyOne, hashOne, null);
          WeakValueReference<Object, Object, ?> valueRefOne =
              segment.newWeakValueReferenceForTesting(entryOne, valueOne);
    Registered: Fri Dec 26 12:43:10 UTC 2025
    - Last Modified: Thu Dec 11 20:07:52 UTC 2025
    - 35.5K bytes
    - Viewed (0)
  10. guava-tests/test/com/google/common/collect/MapMakerInternalMapTest.java

          Segment<Object, Object, ?, ?> segment = map.segments[0];
    
          Object keyOne = new Object();
          Object valueOne = new Object();
          int hashOne = map.hash(keyOne);
          InternalEntry<Object, Object, ?> entryOne = segment.newEntryForTesting(keyOne, hashOne, null);
          WeakValueReference<Object, Object, ?> valueRefOne =
              segment.newWeakValueReferenceForTesting(entryOne, valueOne);
    Registered: Fri Dec 26 12:43:10 UTC 2025
    - Last Modified: Thu Dec 11 20:07:52 UTC 2025
    - 35.5K bytes
    - Viewed (0)
Back to top