allow custom types as indexes when joining tables

This commit is contained in:
Marco Ronchese 2022-12-16 13:09:46 +01:00
parent 4873e43cc5
commit 192826c456

View file

@ -187,6 +187,7 @@ func (s *ScanContext) getGroupKeyInfo(
field := structType.Field(i)
fieldType := indirectType(field.Type)
if !isPrimaryKey(field, primaryKeyOverwrites) {
if !isSimpleModelType(fieldType) {
if fieldType.Kind() != reflect.Struct {
continue
@ -197,8 +198,9 @@ func (s *ScanContext) getGroupKeyInfo(
if len(subType.indexes) != 0 || len(subType.subTypes) != 0 {
ret.subTypes = append(ret.subTypes, subType)
}
}
} else {
if isPrimaryKey(field, primaryKeyOverwrites) {
newTypeName, fieldName := getTypeAndFieldName(typeName, field)
index := s.typeToColumnIndex(newTypeName, fieldName)
@ -208,7 +210,7 @@ func (s *ScanContext) getGroupKeyInfo(
}
ret.indexes = append(ret.indexes, index)
}
}
}