Skip to content

Conversation

Leka74
Copy link

@Leka74 Leka74 commented Aug 26, 2025

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This PR is intended to expose the internal database client for sql-sqlite-bun and sql-sqlite-node packages. My primary reason for doing this was the need to feed the better-auth library with the raw database client, which currently is not available.

I think this can be afterwards added to the other sql packages.

Usage:

const sql = yield* SqliteClient.SqliteClient
const rawClient = yield* sql.rawClient
yield* Effect.sync(() => rawClient.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)"))
yield* Effect.sync(() => rawClient.exec("INSERT INTO test (name) VALUES ('hello')"))
const rows = yield* Effect.try(() => rawClient.prepare("SELECT * FROM test").all())
assert.deepStrictEqual(rows, [{ id: 1, name: "hello" }])

Or in my use-case:

const make = Effect.gen(function*() {
  const sql = yield* SqliteClient.SqliteClient;
  const rawClient = yield* sql.rawClient;

  const auth = yield* Effect.try(() =>
    betterAuth({
      database: rawClient,
      emailAndPassword: {
        enabled: true,
      },
    }),
  );

  return BetterAuthClient.of(auth);
});

Related

  • Related Issue N/A
  • Closes N/A

exposes a `rawClient` property to both of the SqliteClient interfaces to
provide access to the underlying database client
@Leka74 Leka74 requested a review from tim-smart as a code owner August 26, 2025 10:41
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Aug 26, 2025
Copy link

changeset-bot bot commented Aug 26, 2025

⚠️ No Changeset found

Latest commit: 4fc5c2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Leka74 Leka74 changed the base branch from main to next-minor August 26, 2025 11:44
@effect-bot effect-bot force-pushed the next-minor branch 8 times, most recently from c02a39b to 42e92a7 Compare September 2, 2025 13:37
@effect-bot effect-bot force-pushed the next-minor branch 3 times, most recently from 14a9104 to 70b1930 Compare September 2, 2025 21:06
@tim-smart
Copy link
Contributor

A better approach is allowing a raw client to be passed in.

But I'm not sure about this, as currently the client is protected with a semaphore to ensure exclusive use during async transactions. Also, if we decide to change the underlying client it would be a breaking change.

@effect-bot effect-bot force-pushed the next-minor branch 11 times, most recently from b733ef8 to 226b68f Compare September 6, 2025 00:16
@effect-bot effect-bot force-pushed the next-minor branch 3 times, most recently from b64c6b1 to 5306ee2 Compare September 17, 2025 01:46
@effect-bot effect-bot force-pushed the next-minor branch 13 times, most recently from 6016a0d to 28c8bb7 Compare October 6, 2025 22:02
@effect-bot effect-bot force-pushed the next-minor branch 5 times, most recently from 84b4b65 to f30a264 Compare October 14, 2025 14:36
@effect-bot effect-bot force-pushed the next-minor branch 8 times, most recently from 98dbf57 to eeb94dd Compare October 18, 2025 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

2 participants