electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.46k stars 204 forks source link

chore: refactor serialization to be driven by expected types from Postgres #340

Closed samwillis closed 1 month ago

samwillis commented 1 month ago

This is based on #306 but additionally refactors much of the type handling. It also lays the foundation for users to add they own serialises and parser to a PGlite instance either directly or via a plugin/extension - this will come in a later PR.

In the old version type serialization was driven by inferring the type on the JS side, converting to a serialised string, and then setting the type OID on the query for each parameter.

This new version uses the "describe" protocol message to get the expected type of each parameter in a query, and then try and serialise the value based on that. This is based on how it's done in postgres.js

github-actions[bot] commented 1 month ago

Built bundles:

github-actions[bot] commented 1 month ago

🚀 Deployed on https://66f306e52daefb16f4cefa04--pglite.netlify.app

samwillis commented 1 month ago

Hey @alexgleason, could you take a look at this and see if it works with your app?

alexgleason commented 1 month ago

@samwillis My tests are passing with this branch. Thank you!! :+1: