mirror of https://github.com/go-gorm/gorm.git
fix map fields with clickhouse driver
This commit is contained in:
parent
4f6291154b
commit
8a0af58cc5
|
@ -338,7 +338,7 @@ func ParseWithSpecialTableName(dest interface{}, cacheStore *sync.Map, namer Nam
|
|||
|
||||
if _, embedded := schema.cacheStore.Load(embeddedCacheKey); !embedded {
|
||||
for _, field := range schema.Fields {
|
||||
if field.DataType == "" && (field.Creatable || field.Updatable || field.Readable) {
|
||||
if field.DataType == "" && field.GORMDataType == "" && (field.Creatable || field.Updatable || field.Readable) {
|
||||
if schema.parseRelation(field); schema.err != nil {
|
||||
return schema, schema.err
|
||||
} else {
|
||||
|
|
|
@ -19,6 +19,22 @@ func TestParseSchema(t *testing.T) {
|
|||
checkUserSchema(t, user)
|
||||
}
|
||||
|
||||
func TestParseSchemaWithMap(t *testing.T) {
|
||||
type User struct {
|
||||
tests.User
|
||||
Attrs map[string]string `gorm:"type:Map(String,String);"`
|
||||
}
|
||||
|
||||
user, err := schema.Parse(&User{}, &sync.Map{}, schema.NamingStrategy{})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to parse user with map, got error %v", err)
|
||||
}
|
||||
|
||||
if field := user.FieldsByName["Attrs"]; field.DataType != "Map(String,String)" {
|
||||
t.Errorf("failed to parse user field Attrs")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSchemaWithPointerFields(t *testing.T) {
|
||||
user, err := schema.Parse(&User{}, &sync.Map{}, schema.NamingStrategy{})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue