improvements
This commit is contained in:
parent
f17e4f5cd6
commit
6300ab092b
|
@ -250,10 +250,10 @@ func (parser *Parser) parseFieldWithTags(table *schemas.Table, fieldIndex int, f
|
||||||
}
|
}
|
||||||
|
|
||||||
if col.SQLType.Name == "" {
|
if col.SQLType.Name == "" {
|
||||||
if col.IsJSON {
|
if col.IsJSONB { // check is jsonb first because it is also json
|
||||||
col.SQLType = schemas.SQLType{Name: schemas.Json}
|
|
||||||
} else if col.IsJSONB {
|
|
||||||
col.SQLType = schemas.SQLType{Name: schemas.Jsonb}
|
col.SQLType = schemas.SQLType{Name: schemas.Jsonb}
|
||||||
|
} else if col.IsJSON {
|
||||||
|
col.SQLType = schemas.SQLType{Name: schemas.Json}
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
col.SQLType, err = parser.getSQLTypeByType(field.Type)
|
col.SQLType, err = parser.getSQLTypeByType(field.Type)
|
||||||
|
|
|
@ -577,7 +577,7 @@ func TestParseWithJSONB(t *testing.T) {
|
||||||
assert.EqualValues(t, "struct_with_jsonb", table.Name)
|
assert.EqualValues(t, "struct_with_jsonb", table.Name)
|
||||||
assert.EqualValues(t, 1, len(table.Columns()))
|
assert.EqualValues(t, 1, len(table.Columns()))
|
||||||
assert.EqualValues(t, "default1", table.Columns()[0].Name)
|
assert.EqualValues(t, "default1", table.Columns()[0].Name)
|
||||||
assert.True(t, table.Columns()[0].IsJSON)
|
assert.True(t, table.Columns()[0].IsJSONB)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseWithSQLType(t *testing.T) {
|
func TestParseWithSQLType(t *testing.T) {
|
||||||
|
|
|
@ -306,6 +306,7 @@ func JSONTagHandler(ctx *Context) error {
|
||||||
|
|
||||||
func JSONBTagHandler(ctx *Context) error {
|
func JSONBTagHandler(ctx *Context) error {
|
||||||
ctx.col.IsJSONB = true
|
ctx.col.IsJSONB = true
|
||||||
|
ctx.col.IsJSON = true // jsonb is also json
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue