File tree Expand file tree Collapse file tree
pkg/db/dbutils/pgtypeutils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,3 +19,22 @@ func DecodeInt2(value pgtype.Int2) *int16 {
1919 }
2020 return & value .Int16
2121}
22+
23+ func EncodeUInt2 (value * uint16 ) pgtype.Int2 {
24+ var v int16
25+ if value != nil {
26+ v = int16 (* value )
27+ }
28+ return pgtype.Int2 {
29+ Int16 : v ,
30+ Valid : value != nil ,
31+ }
32+ }
33+
34+ func DecodeUInt2 (value pgtype.Int2 ) * uint16 {
35+ if ! value .Valid {
36+ return nil
37+ }
38+ v := uint16 (value .Int16 )
39+ return & v
40+ }
Original file line number Diff line number Diff line change @@ -19,3 +19,22 @@ func DecodeInt4(value pgtype.Int4) *int32 {
1919 }
2020 return & value .Int32
2121}
22+
23+ func EncodeUInt4 (value * uint32 ) pgtype.Int4 {
24+ var v int32
25+ if value != nil {
26+ v = int32 (* value )
27+ }
28+ return pgtype.Int4 {
29+ Int32 : v ,
30+ Valid : value != nil ,
31+ }
32+ }
33+
34+ func DecodeUInt4 (value pgtype.Int4 ) * uint32 {
35+ if ! value .Valid {
36+ return nil
37+ }
38+ v := uint32 (value .Int32 )
39+ return & v
40+ }
Original file line number Diff line number Diff line change @@ -19,3 +19,22 @@ func DecodeInt8(value pgtype.Int8) *int64 {
1919 }
2020 return & value .Int64
2121}
22+
23+ func EncodeUInt8 (value * uint64 ) pgtype.Int8 {
24+ var v int64
25+ if value != nil {
26+ v = int64 (* value )
27+ }
28+ return pgtype.Int8 {
29+ Int64 : v ,
30+ Valid : value != nil ,
31+ }
32+ }
33+
34+ func DecodeUInt8 (value pgtype.Int8 ) * uint64 {
35+ if ! value .Valid {
36+ return nil
37+ }
38+ v := uint64 (value .Int64 )
39+ return & v
40+ }
You can’t perform that action at this time.
0 commit comments