Add support for database uuid types.
This commit is contained in:
parent
2c7a9f5058
commit
37b0a6445b
6 changed files with 126 additions and 44 deletions
|
|
@ -40,14 +40,14 @@ func (c ColumnInfo) ToSqlBuilderColumnType() string {
|
|||
return "IntegerColumn"
|
||||
case "date", "timestamp without time zone", "timestamp with time zone":
|
||||
return "TimeColumn"
|
||||
case "text", "character", "character varying", "bytea":
|
||||
case "text", "character", "character varying", "bytea", "uuid":
|
||||
return "StringColumn"
|
||||
case "real":
|
||||
return "NumericColumn"
|
||||
case "numeric", "double precision":
|
||||
return "NumericColumn"
|
||||
default:
|
||||
fmt.Println("Unknownl type: " + c.DataType + ", using string instead.")
|
||||
fmt.Println("Unknownl type: " + c.DataType + ", using string column instead.")
|
||||
return "StringColumn"
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func (c ColumnInfo) GoBaseType() string {
|
|||
} else {
|
||||
switch c.DataType {
|
||||
case "USER-DEFINED":
|
||||
return c.EnumName
|
||||
return snaker.SnakeToCamel(c.EnumName)
|
||||
case "boolean":
|
||||
return "bool"
|
||||
case "smallint":
|
||||
|
|
@ -86,8 +86,10 @@ func (c ColumnInfo) GoBaseType() string {
|
|||
return "float32"
|
||||
case "numeric", "double precision":
|
||||
return "float64"
|
||||
case "uuid":
|
||||
return "uuid.UUID"
|
||||
default:
|
||||
fmt.Println("Unknown go map type: " + c.DataType + ", using string instead.")
|
||||
fmt.Println("Unknown go map type: " + c.DataType + ", " + c.EnumName + ", using string instead.")
|
||||
return "string"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@ func (t TableInfo) GetImports() []string {
|
|||
for _, column := range t.Columns {
|
||||
columnType := column.GoBaseType()
|
||||
|
||||
if columnType == "time.Time" {
|
||||
switch columnType {
|
||||
case "time.Time":
|
||||
imports["time.Time"] = "time"
|
||||
case "uuid.UUID":
|
||||
imports["uuid.UUID"] = "github.com/google/uuid"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue