Skip to content

feat: Add Effect adapters for Expo SQLite and OP-SQLite - #6035

Open
8times4 wants to merge 1 commit into
drizzle-team:rc5from
8times4:add-op-and-expo-sqlite-effect
Open

feat: Add Effect adapters for Expo SQLite and OP-SQLite#6035
8times4 wants to merge 1 commit into
drizzle-team:rc5from
8times4:add-op-and-expo-sqlite-effect

Conversation

@8times4

@8times4 8times4 commented Jul 19, 2026

Copy link
Copy Markdown

tldr; Adds Effect integrations for Expo SQLite and OP-SQLite, based on the patterns used by the existing Drizzle Effect adapters

Changes:

  • Adds effect-expo-sqlite and effect-op-sqlite drivers, sessions, migrators, and exports.

  • Bridges native transactions using Effect.callback so the interruption reaches the transaction fiber and waits for commit or rollback.

  • Makes nested savepoint cleanup uninterruptible.

  • Explicitly rejects unsupported immediate and exclusive transaction behavior instead of silently discarding it.

  • Keeps Expo :memory: transactions on the original connection.

  • Supports generated mobile migration bundles using journal metadata.

  • Defers migration parsing into the Effect execution boundary.

  • 1,105 unit tests passed; 7 skipped.

  • Native transaction behavior is tested with injected Expo/OP-SQLite client fakes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c540bae561

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +185 to +187
nativeTransaction = client.databaseName === ':memory:'
? client.withTransactionAsync(() => runTransaction(client))
: client.withExclusiveTransactionAsync(runTransaction);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Support current Expo transaction fallbacks

When this adapter is used with newer expo-sqlite versions allowed by the peer range, SQLiteDatabase exposes databasePath rather than databaseName, and withExclusiveTransactionAsync is not supported on web. In those cases this check falls through to the exclusive transaction path even for ':memory:' databases, so web transactions throw immediately and deserialized/in-memory databases run the transaction against a fresh empty connection instead of the user's database. Please detect the current path/API support before choosing the exclusive helper.

Useful? React with 👍 / 👎.

Comment on lines +80 to +85
if (mode === 'arrays') return this.executeRaw(query.sql, params);
return this.execute(query.sql, params).pipe(Effect.map(({ rows }) => rows?._array ?? []));
},
get: (params) => {
if (mode === 'arrays') return this.executeRaw(query.sql, params).pipe(Effect.map((rows) => rows[0]));
return this.execute(query.sql, params).pipe(Effect.map(({ rows }) => rows?._array?.[0]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle current OP-SQLite result shapes

With current @op-engineering/op-sqlite versions allowed by this package's peer range, executeAsync returns rows as an array rather than { _array }, and raw execution returns a result object with rawRows. In those installs, object-mode selects on this line return []/undefined even when rows exist, while array-mode/values() returns the wrapper object instead of arrays. Please normalize both the legacy _array shape and the current array/rawRows shape before returning results.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant