-
Notifications
You must be signed in to change notification settings - Fork 23
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
base: main
Are you sure you want to change the base?
Conversation
|
16b4268
to
fdc70db
Compare
I didn't even know that was possible... Probably worth adding an explicit test for |
67fed1f
to
db0151b
Compare
table.columns.push({ | ||
name: column.attname, | ||
sqlite_type: sync_rules.expressionTypeFromPostgresType(pg_type).typeFlags, | ||
sqlite_type: sync_rules.ExpressionType.fromTypeText(knownType.sqliteType()).typeFlags, |
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.
It is worth noting that this doesn't take the current sync rules / compatibility options into account (I'm not sure if they're available here). So a DOMAIN
type wrapping FLOAT
would get represented as TYPE_REAL
instead of TYPE_TEXT
, even though we might replicate values as strings.
I think this may be fine because types are implemented as casts on the client-side, so the actual value returned by the view will be correct.
d10c33e
to
1291598
Compare
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()
.