effect icon indicating copy to clipboard operation
effect copied to clipboard

Add @effect/sql-pglite package

Open evelant opened this issue 8 months ago • 12 comments

Type

  • [ ] Refactor
  • [x] Feature
  • [ ] Bug Fix
  • [ ] Optimization
  • [ ] Documentation Update

Description

Add @effect/sql-pglite package. An @effect/sql driver for PGlite, single user postgresql in the browser or node.

Related

  • Related Issue #
  • Closes #

evelant avatar Apr 03 '25 17:04 evelant

🦋 Changeset detected

Latest commit: ad8a7ae6df190eca3726d4fe8ca3a492733408b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/sql-pglite Minor

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

changeset-bot[bot] avatar Apr 03 '25 17:04 changeset-bot[bot]

Not sure why the lint and docgen failed, they pass on my branch locally.

evelant avatar Apr 04 '25 16:04 evelant

@evelant, thanks for doing this! Have been looking for a solution to write tests against. Not gotten a chance to fully try it out yet, but figured I could help unblock the pipeline failures to hopefully get this in sooner.

To fix the codegen, run pnpm codegen. It fixes some doc comments.

To fix the docgen, add this to your docgen.json.

{
  ...,
  "examplesCompilerOptions": {
    "noEmit": true,
    "strict": true,
    "skipLibCheck": true,
    "moduleResolution": "Bundler",
    "module": "ES2022",
    "target": "ES2022",
    "lib": ["ES2022", "DOM"],
    "paths": {
      "@effect/experimental": ["../../../experimental/src/index.js"],
      "@effect/experimental/*": ["../../../experimental/src/*.js"],
      "@effect/platform": ["../../../platform/src/index.js"],
      "@effect/platform/*": ["../../../platform/src/*.js"],
      "@effect/sql": ["../../../sql/src/index.js"],
      "@effect/sql/*": ["../../../sql/src/*.js"],
      "effect": ["../../../effect/src/index.js"],
      "effect/*": ["../../../effect/src/*.js"]
    }
  }
}

Ohter feedback:

  1. Some of the json has inconsistent formatting which can be fixed with pnpm prettier packages/sql-pglite/**/*.json -w.
  2. Missing entry in the root /docs/index.md.
  3. (Opinion) Instead of PgLite, would it make more sense to follow the naming of Sqlite, so Pglite. If it is PgLite, the camel to kabob conversion I think would make the package name sql-pg-lite.

caubut-charter avatar May 01 '25 02:05 caubut-charter

Thanks for the feedback! I've had to put down my side project using pglite for now but as soon as I can find time I'll update the PR. As for the naming it's extra confusing because PGlite uses PGlite not Pglite or PgLite. I think my fingers just typed PgLite out of habit haha. I think you're right, probably best to change it to Pglite to match Sqlite. Ah I see how the formatting got a little off too -- prettier plugin in vscode auto-formatting on save.

evelant avatar May 01 '25 16:05 evelant

I finally got around to cleaning this up. Sorry for the long delay!

evelant avatar Jun 03 '25 22:06 evelant

Any more changes needed or can this be merged now?

evelant avatar Jun 18 '25 17:06 evelant

I think you probably have to ask Tim for a review manually. Because on my PR, where I had a lot of changes to SQL packages, he was automatically attached as per the CODEOWNERS file, while it seems this automation doesn't work when you are adding a completely new SQL-related package. Maybe you have to even add a new row there

nikelborm avatar Jun 30 '25 17:06 nikelborm

Fixed failing CI in evelant/effect#3

image

nikelborm avatar Jul 08 '25 10:07 nikelborm

@tim-smart Whenever you get a chance I'd appreciate your feedback on this so I can make any necessary changes, thanks!

evelant avatar Jul 22 '25 22:07 evelant

This is especially needed now that @effect/sql-pg uses pg instead of postgres, and has lost support for the socket configuration option, which I was previously using to integrate with pglite for integration-testing database code.

bwbuchanan avatar Nov 04 '25 13:11 bwbuchanan

Sorry I dropped the ball on finishing this PR. I'll pick it up again ASAP.

evelant avatar Nov 04 '25 14:11 evelant