-
Notifications
You must be signed in to change notification settings - Fork 302
Feature Request / Idea: PGlite integration? #1000
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
Comments
This would be so awesome since it'd make it trivial to write high performance unit tests in postgres.js apps! |
Unfortunately pglite is tightly coupled to a single-user mode for postgres to avoid having to fork processes per-connection (which postgres does and wasm doesn't support) and thus it doesn't actually spin up a server / doesn't speak the normal wire protocol. Integrating it with postgres.js thus seems pretty nontrivial I think. |
I'm currently exploring a separate but related goal and came across pg-gateway, which implements the postgres wire protocol in TS. It appears built to solve this problem, and they have an example of using it to "wrap" PGLite. |
Did you try it? Looks like a flurry of activity 8 mos ago. Great find! |
@rmnoon I just spent a bit of time today getting this working here. I want to note a few things: Handling extra ReadyForQuery messagesThere is an insidious bug between PGlite and postgres.js that was pretty hard to track down. Essentially, PGlite is sending extra ReadyForQuery at the end of each socket message. This appears to be a bug in PGlite itself, and while that scenario appears to be undefined behavior in this client, the effect I saw was indefinite hanging. It's not clear to me if this is a scenario is hypothetically possible for a "well behaving" postgres server, or if this is simply a violation of the postgres protocol that should never actually happen. I currently use Adding
|
Related (I didn't want to flood the issues with feature requests at the time): #927 I feel like the easiest way to get this in the meantime is building a custom wrapper that wraps either postgres.js or pglite depending on whether you are running tests / dev environment. Drizzle could act as an intermediary as it supports both postgres.js / pglite and it has a sql template literal, but unfortunately its template literal isn't as powerful as postgres.js. |
Description
Support PGLite (wasm postgres)
Motivation
Allows user to use this library (postgres) with local version of postgres without needing to install postgres directly on their computer or setup a container.
I love the API for this libray; its so flexible and well thought out 😭
The text was updated successfully, but these errors were encountered: