-
Notifications
You must be signed in to change notification settings - Fork 30
Better decoding of custom postgres types #339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
16b4268 to
fdc70db
Compare
I didn't even know that was possible... Probably worth adding an explicit test for |
67fed1f to
db0151b
Compare
d10c33e to
1291598
Compare
bf472b6 to
dd082fc
Compare
dd082fc to
0eefce1
Compare
| "date-fns": "^4.1.0", | ||
| "pgwire": "github:kagis/pgwire#f1cb95f9a0f42a612bb5a6b67bb2eb793fc5fc87" | ||
| "pgwire": "github:kagis/pgwire#f1cb95f9a0f42a612bb5a6b67bb2eb793fc5fc87", | ||
| "vitest": "^3.0.5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, we need to be careful about adding dependencies like this in dependencies - should be in devDependencies instead. This can add some unnecessary dependencies to the Docker image - see #361.
This adds a compatibility option that, when enabled, will map custom postgres types into appropriate structures instead of syncing the raw representation.
Today, we support a static list of builtin Postgres types. Any other type will be synced as the underlying text representation as receive from the replication stream.
This PR improves that to add support for custom types. These types are resolved by querying their description from
pg_type. Specifically, this supports:We also need to support nested types composed from these (e.g. a composite type could reference an array of a domain type that is itself another composite type). So we perform a BFS traversal through types when fetching them, and the decoding logic is recursive to handle these structures.
To decode the tuples that composite values are encoded as, this also refactors how arrays are parsed (since the structure is quite similar). The new decoder also supports arrays with a non-standard delimiter (which is also fetched from
pg_type).Closes #299.
TODOS:
getConnectionSchema().