forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_column_type.go
49 lines (45 loc) · 1.08 KB
/
sql_column_type.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
38
39
40
41
42
43
44
45
46
47
48
49
package types
// SQLColumnType to store generic SQL column types
type SQLColumnType int
// generic SQL column types
const (
SQLColumnTypeBool SQLColumnType = iota
SQLColumnTypeByteA
SQLColumnTypeInt
SQLColumnTypeSerial
SQLColumnTypeText
SQLColumnTypeVarchar
SQLColumnTypeTimeStamp
SQLColumnTypeNumeric
SQLColumnTypeJSON
SQLColumnTypeBigInt
)
func (ct SQLColumnType) String() string {
switch ct {
case SQLColumnTypeBool:
return "bool"
case SQLColumnTypeByteA:
return "bytea"
case SQLColumnTypeInt:
return "int"
case SQLColumnTypeSerial:
return "serial"
case SQLColumnTypeText:
return "text"
case SQLColumnTypeVarchar:
return "varchar"
case SQLColumnTypeTimeStamp:
return "timestamp"
case SQLColumnTypeNumeric:
return "numeric"
case SQLColumnTypeJSON:
return "json"
case SQLColumnTypeBigInt:
return "bigint"
}
return "unknown SQL type"
}
// IsNumeric determines if an sqlColumnType is numeric
func (ct SQLColumnType) IsNumeric() bool {
return ct == SQLColumnTypeInt || ct == SQLColumnTypeSerial || ct == SQLColumnTypeNumeric || ct == SQLColumnTypeBigInt
}