Skip to content

Commit

Permalink
Fix returning a proper data type for UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Feb 1, 2025
1 parent caee9be commit 373538f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/test-data-types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ INSERT INTO test_table (
'2024-01-01 12:00:00.123', -- timestamp_ms_column
'2024-01-01 12:00:00.123456-05', -- timestamptz_column
'2024-01-01 12:00:00.123-05', -- timestamptz_ms_column
gen_random_uuid(), -- uuid_column
'58a7c845-af77-44b2-8664-7ca613d92f04', -- uuid_column
decode('48656c6c6f', 'hex'), -- bytea_column
'1 mon 2 days 01:00:01.000001'::INTERVAL, -- interval_column
'(1, 2)'::POINT, -- point_column
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const VERSION = "0.30.2"
const VERSION = "0.30.3"

func main() {
config := LoadConfig()
Expand Down
4 changes: 2 additions & 2 deletions src/query_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,9 @@ func (queryHandler *QueryHandler) columnTypeOid(col *sql.ColumnType) uint32 {
case "TIMESTAMP[]":
return pgtype.TimestampArrayOID
case "BLOB":
return pgtype.ByteaOID
return pgtype.UUIDOID
case "BLOB[]":
return pgtype.ByteaArrayOID
return pgtype.UUIDArrayOID
default:
if strings.HasPrefix(col.DatabaseTypeName(), "DECIMAL") {
if strings.HasSuffix(col.DatabaseTypeName(), "[]") {
Expand Down
6 changes: 3 additions & 3 deletions src/query_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,14 @@ func TestHandleQuery(t *testing.T) {
"types": {Uint32ToString(pgtype.TimestampOID)},
"values": {"2024-01-01 07:00:00.12"},
},
"SELECT uuid_column FROM public.test_table WHERE uuid_column IS NOT NULL": {
"SELECT uuid_column FROM public.test_table WHERE uuid_column = '58a7c845-af77-44b2-8664-7ca613d92f04'": {
"description": {"uuid_column"},
"types": {Uint32ToString(pgtype.ByteaOID)},
"types": {Uint32ToString(pgtype.UUIDOID)},
"values": {"58a7c845-af77-44b2-8664-7ca613d92f04"},
},
"SELECT uuid_column FROM public.test_table WHERE uuid_column IS NULL": {
"description": {"uuid_column"},
"types": {Uint32ToString(pgtype.ByteaOID)},
"types": {Uint32ToString(pgtype.UUIDOID)},
"values": {""},
},
"SELECT bytea_column FROM public.test_table WHERE bytea_column IS NOT NULL": {
Expand Down

0 comments on commit 373538f

Please sign in to comment.