-
Notifications
You must be signed in to change notification settings - Fork 173
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
feat (client): support for PG on the client #1038
Conversation
9987b45
to
21d114b
Compare
570b24f
to
37bb5b9
Compare
37bb5b9
to
95f3314
Compare
d17b56b
to
337ee9d
Compare
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.
Amazing work! Left a few minor comments, might do a second pass/review later!
8a93815
to
3dcf5a6
Compare
e2e test |
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.
Did a second pass, looking good!
When client reconnects, Electric restores some information from the DB we then checked that that information was gone from the DB. However, CI is slow and Electric did not yet restore the information by the time we checked that the information was gone from the DB. Now added an explicit match in the e2e tests to make sure we only check the DB state after that information has been restored by Electric. |
6ddf542
to
4b861d7
Compare
ba47f26
to
360e85e
Compare
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.
Last batch of comments. Honestly mostly nitpicks, although I really want package.json
and deferFKs
addressed before we proceed. Feel free to ignore/address the rest as you see fit.
Very good work overall, speaks to a reasonable code organisation that this change was actually impressively reviewable and contained
@kevin-dp Don't forget to add a changeset. |
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.
Thanks for addressing feedback! Final function deletion and LGTM
Enables using Linearlite with PGlite or wa-sqlite by setting the `ELECTRIC_CLIENT_DB` env var to either `wa-sqlite` or `pglite`. This can be done in the `.env` file or any other standard way. It will be embedded into the build so a build will be for one or the other. To be merged after #1038 with the `electric-sql` rep either pointing at a canary build or a published version.
Preview: https://deploy-preview-128--electric-sql-website.netlify.app node-postgres driver docs may need editing if a change is made due to this: #1038 (comment)
Preview: https://deploy-preview-128--electric-sql-website.netlify.app node-postgres driver docs may need editing if a change is made due to this: #1038 (comment)
This PR adds support for Postgres on the client:
BundleMigrator
To test this PR you will need to:
alco/vax-1659-postgresql-dialect
Limitations:
NaN
for floating-point numbers. Our triggers do some casting of these values, need to test this with some e2e tests or actual tauri application to see if it works or not.A couple of things to note regarding the implementation:
jsonb
adds whitespace and re-orders keys. Whereas, SQLite has no whitespace and preserves the ordering of keys. So in PG we usejson
instead ofjsonb
and strip any whitespace but that has the side effect of also removingnull
values. Hence, we also removenull
values in SQLite.DEFERRABLE
cannot ALTER TABLE "parent" because it has pending trigger events
Remains to be done (perhaps in a follow-up PR):
For reviewers:
src/migrators/query-builder/builder.ts
defines an abstractQueryBuilder
class that every dialect must implementsrc/migrators/query-builder/sqliteBuilder.ts
and ``src/migrators/query-builder/pgBuilder.ts` implement the abstract class for SQLite and Postgres respectively'SQLite'
. Postgres drivers'electrify
function pass'Postgres'
dialect through this config object. The DAL checks the dialect in order to apply the right conversions from JS values to SQLite/PG values and back.src/migrators/bundle.ts
,src/migrators/schema.ts
, andsrc/migrators/triggers.ts
to use the dialect-specific query builder object.src/satellite/process.ts
) has been changed to use the dialect-specific query builder for constructing its specialised queries.Converter
interface (src/client/conversions/converter.ts
).src/client/conversions/sqlite.ts
and 1 for PGsrc/client/conversions/postgres.ts
src/util/encoders
).