-
Notifications
You must be signed in to change notification settings - Fork 4
/
typerow.go
37 lines (35 loc) · 1.01 KB
/
typerow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package model
import (
"projectforge.dev/projectforge/app/lib/types"
"projectforge.dev/projectforge/app/project/export/enum"
"projectforge.dev/projectforge/app/util"
)
func ToGoRowType(t types.Type, nullable bool, pkg string, enums enum.Enums, database string) (string, error) {
switch t.Key() {
case types.KeyAny, types.KeyList, types.KeyMap, types.KeyValueMap, types.KeyReference:
if database == util.DatabaseSQLite || database == util.DatabaseSQLServer {
return types.KeyString, nil
}
return "json.RawMessage", nil
default:
if t.Key() == types.KeyUUID && database == util.DatabaseSQLServer {
if nullable {
return "*any", nil
}
return "mssql.UniqueIdentifier", nil
}
if t.Scalar() && nullable {
switch t.Key() {
case types.KeyString:
return "util.NilString", nil
case types.KeyInt:
return "util.NilInt64", nil
case types.KeyFloat:
return "util.NilFloat64", nil
case types.KeyBool:
return "util.NilBool", nil
}
}
return ToGoType(t, nullable, pkg, enums)
}
}