Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for POLYMORPHICTYPE (0.16 sec)

  1. schema/relationship_test.go

    		type Toy struct {
    			ID    int
    			Name  string
    			RefId int
    			Type  string
    		}
    
    		type Cat struct {
    			ID   int
    			Name string
    			Toy  Toy `gorm:"polymorphic:Owner;polymorphicType:Type;polymorphicId:RefId"`
    		}
    
    		s, err := schema.Parse(&Cat{}, &sync.Map{}, schema.NamingStrategy{})
    		if err != nil {
    			t.Fatalf("Failed to parse schema, got error %v", err)
    		}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 25.5K bytes
    - Viewed (0)
  2. schema/relationship.go

    }
    
    // hasPolymorphicRelation check if has polymorphic relation
    // 1. `POLYMORPHIC` tag
    // 2. `POLYMORPHICTYPE` and `POLYMORPHICID` tag
    func hasPolymorphicRelation(tagSettings map[string]string) bool {
    	if _, ok := tagSettings["POLYMORPHIC"]; ok {
    		return true
    	}
    
    	_, hasType := tagSettings["POLYMORPHICTYPE"]
    	_, hasId := tagSettings["POLYMORPHICID"]
    
    	return hasType && hasId
    }
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Mon Apr 15 03:20:20 GMT 2024
    - 22.4K bytes
    - Viewed (0)
Back to top