Skip to content

Commit

Permalink
Add []uuid data type
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Oct 28, 2023
1 parent 72e21ef commit 9872ec6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func main() {
| TsVector | tsvector |
| TxIDSnapshot | txid_snapshot |
| UUID | uuid |
| UUIDArray | []uuid |
| XML | xml |
| Int4Range | int4range |
| Int4MultiRange | int4multirange |
Expand Down
8 changes: 5 additions & 3 deletions desc/data_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const (
TsVector // TsVector represents a text search document that contains lexemes and their positions.
TxIDSnapshot // TxIDSnapshot represents the state of transactions at some point in time. It can be used to implement multiversion concurrency control (MVCC).
UUID // UUID represents an universally unique identifier (16 bytes).
UUIDArray // UUIDArray represents an array of universally unique identifiers (16 bytes).
XML // XML represents an XML data structure in text format.
// Multiranges: https://www.postgresql.org/docs/14/rangetypes.html#RANGETYPES-BUILTIN.
Int4Range // Range of integer, int4multirange.
Expand Down Expand Up @@ -144,6 +145,7 @@ var dataTypeText = map[DataType][]string{ // including their aliases.
TsVector: {"tsvector"},
TxIDSnapshot: {"txid_snapshot"},
UUID: {"uuid"},
UUIDArray: {"[]uuid"},
XML: {"xml"},
Int4Range: {"int4range"},
Int4MultiRange: {"int4multirange"},
Expand Down Expand Up @@ -191,7 +193,7 @@ func (t DataType) IsString(s string) bool {
// IsArray returns true if the data type is an array.
func (t DataType) IsArray() bool {
switch t {
case BigIntArray, IntegerArray, IntegerDoubleArray, CharacterArray, CharacterVaryingArray, TextArray, TextDoubleArray:
case BigIntArray, IntegerArray, IntegerDoubleArray, CharacterArray, CharacterVaryingArray, TextArray, TextDoubleArray, UUIDArray:
return true
default:
return false
Expand Down Expand Up @@ -328,13 +330,13 @@ func dataTypeToGoType(dataType DataType) reflect.Type {
return arrayIntegerTyp
case IntegerDoubleArray:
return doubleArrayIntegerTyp
case CharacterVaryingArray:
case CharacterVaryingArray, TextArray, UUIDArray:
return arrayStringTyp
case Boolean:
return booleanTyp
case TextDoubleArray:
return doubleArrayStringTyp
case Timestamp:
case Time, TimeTZ, Timestamp, TimestampTZ:
return timeType
case Interval:
return timeDurationTyp
Expand Down

0 comments on commit 9872ec6

Please sign in to comment.