feat: Add Effect adapters for Expo SQLite and OP-SQLite - #6035
Conversation
There was a problem hiding this comment.
💡 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".
| nativeTransaction = client.databaseName === ':memory:' | ||
| ? client.withTransactionAsync(() => runTransaction(client)) | ||
| : client.withExclusiveTransactionAsync(runTransaction); |
There was a problem hiding this comment.
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 👍 / 👎.
| 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])); |
There was a problem hiding this comment.
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 👍 / 👎.
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-sqliteandeffect-op-sqlitedrivers, 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.