fix: normalize postgres UUIDs to strings - #3806
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request introduces a NormalizeValue utility function to convert PostgreSQL UUID values (OID 2950) from [16]byte to their string representation, applying it across AlloyDB, Cloud SQL Postgres, Postgres, and YugabyteDB sources. It also adds corresponding unit tests. The review feedback suggests extending this normalization to support PostgreSQL UUID arrays (OID 2951) and provides the necessary code and test cases to implement this improvement.
db72f9f to
8aad0bf
Compare
f941889 to
bc3e155
Compare
|
also included some Zizmor workflow fixes under |
TAG=agy CONV=4ebccd78-3deb-4d92-b29e-6b1a36f2308a
TAG=agy CONV=08322a1d-4754-4ca9-ae73-4e91bf2b280c
Description
Fixes a bug where PostgreSQL UUID columns were being serialized as numerical arrays (e.g., [1, 158, 103, ...]) in JSON output instead of standard hyphenated strings.
Root Cause
The generic results.Values() method in the pgx driver returns UUIDs as [16]byte fixed arrays. Go's standard encoding/json package serializes fixed arrays of bytes as numerical arrays rather than strings.
Solution
Introduced a centralized NormalizeValue helper function in internal/sources/util.go that intercepts values based on their PostgreSQL Object Identifier (OID). If it detects a UUID OID (2950) and a [16]byte type, it converts it into a standard UUID string via the github.com/google/uuid package.
Impact
Consistent string serialization for UUIDs across all Postgres-compatible drivers (postgres, alloydb-postgres, cloud-sql-postgres, yugabytedb). Added unit tests to internal/sources/util_test.go to guarantee reliability.
PR Checklist
!if this involve a breaking change🛠️ Fixes #3795