-
-
Notifications
You must be signed in to change notification settings - Fork 375
Add @effect/sql-pglite package #4692
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: next-minor
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ad8a7ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
02d328c
to
1ea11b9
Compare
Not sure why the lint and docgen failed, they pass on my branch locally. |
4cba33b
to
5c9e640
Compare
f265f41
to
0fd314b
Compare
f2312ff
to
7e10415
Compare
@tim-smart Whenever you get a chance I'd appreciate your feedback on this so I can make any necessary changes, thanks! |
Migrator.MigrationError | SqlError, | ||
FileSystem | Path | PgliteClient | Client.SqlClient | R2 | ||
> = Migrator.make({ | ||
dumpSchema(path, table) { |
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.
Does pglite support pg_dump?
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.
executeValues(sql: string, params: ReadonlyArray<Primitive>) { | ||
// PGlite doesn't have a values() method like postgres.js | ||
// We'll just return the regular query results | ||
return this.execute(sql, params, (r) => Object.values(r)) |
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.
I think you will need an .map here? The results will be an array?
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.
Maybe I was confused about what executeValues should return. Is it supposed to be an array of arrays of values? That's what this should do since the function param is the row transform, it transforms each row object into an array of values.
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.
r
will be an array of objects here, so you will need to map over each item.
) { | ||
// PGlite doesn't have a cursor method like postgres.js | ||
// We'll fetch all results at once and convert to a stream | ||
return Stream.fromEffect( |
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.
You can use Stream.fromIterableEffect
constructor(private readonly pg: PGlite) {} | ||
|
||
private run(query: Promise<any>) { | ||
return Effect.async<ReadonlyArray<any>, SqlError>((resume) => { |
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.
You can switch to tryPromise here
extensions: options.extensions ? (client as any) : ({} as any), | ||
listen: (channel: string) => | ||
Stream.asyncPush<string, SqlError>((emit) => | ||
Effect.tryPromise({ |
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.
You would use Effect.acquireRelease here. I think this would immediately unsubscribe.
Effect.tryPromise({ | ||
try: () => client.query(`NOTIFY ${channel}, '${payload}'`), | ||
catch: (cause) => new SqlError({ cause, message: "Failed to notify" }) | ||
}).pipe(Effect.map(() => void 0)) |
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.
}).pipe(Effect.map(() => void 0)) | |
}).pipe(Effect.asVoid) |
|
||
test("should work", () => expect(true)) | ||
describe("PgliteClient", () => { |
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.
test("should work", () => expect(true)) | |
describe("PgliteClient", () => { | |
describe("PgliteClient", () => { |
Type
Description
Add @effect/sql-pglite package. An @effect/sql driver for PGlite, single user postgresql in the browser or node.
Related