Repository navigation
support new arch, Expo 53+ - #59
song-react wants to merge 28 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR adds a synchronous native Prisma execution entry point, updates JavaScript proxy routing and type contracts, patches the installed React Native runtime at install time, and changes platform-specific installation and header-resolution logic. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d89adffc-66b7-4720-a069-b88a786e04fb
📒 Files selected for processing (5)
android/src/main/java/com/prisma/PrismaModule.javacopy-migrations.shcpp/QueryEngineHostObject.hcpp/react-native-prisma.cppios/Prisma.mm
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cpp/react-native-prisma.cpp`:
- Around line 203-206: The query response path in the Prisma JSI bridge can
crash when prisma_query returns a null response without setting error_ptr.
Update the response handling in react-native-prisma.cpp near the code that
creates the JSI string to mirror the transaction handler null-response guard:
check response for null before calling jsi::String::createFromUtf8(rt,
response), and return a proper error/empty result path instead of converting a
null pointer.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1e65979e-48b5-4fa6-9ea0-49510fe14253
📒 Files selected for processing (2)
cpp/react-native-prisma.cppsrc/index.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/patch-prisma-runtime.cjs`:
- Around line 19-22: The runtime patch in patch-prisma-runtime.cjs can end up
writing code that references __prismaReactNativeFastRead without having inserted
the helper first. Update the patch flow around the source.replace logic to
verify the marker/helper was actually injected before any later replacements or
writeFileSync output, and treat a missing "use strict"; match as an unsupported
runtime shape that should fail early instead of emitting a broken runtime.
- Around line 72-77: The postinstall patch in patchPrismaRuntime currently only
warns when the Prisma React Native runtime patch fails, which lets installation
continue with an unpatched runtime. Update the catch path in patchPrismaRuntime
to treat failures as non-recoverable: propagate the error, rethrow it, or set a
non-zero exit code after logging, so unsupported runtime shapes, permission
issues, and write failures cause installation to fail. Keep the existing error
context from the catch block, but ensure the failure is surfaced instead of
silently succeeding.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 78c68b34-b6f8-4f23-941a-6449eacd90a8
📒 Files selected for processing (2)
package.jsonscripts/patch-prisma-runtime.cjs
| source = source.replace( | ||
| '"use strict";', | ||
| `"use strict";var ${marker}=e=>{try{let t=e?.query?.arguments??{};if(t.distinct!=null)return!1;if(e?.action==="findUnique"||e?.action==="findFirst")return!0;return e?.action==="findMany"&&typeof t.take==="number"&&Number.isFinite(t.take)&&Math.abs(t.take)<=100}catch{return!1}};` | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Verify the helper insertion before writing the patched runtime.
If "use strict"; is absent but the later string matches still succeed, Line 53 writes a runtime that calls an undefined __prismaReactNativeFastRead. Treat a missed helper insertion as an unsupported runtime shape.
Proposed fix
- source = source.replace(
- '"use strict";',
- `"use strict";var ${marker}=e=>{try{let t=e?.query?.arguments??{};if(t.distinct!=null)return!1;if(e?.action==="findUnique"||e?.action==="findFirst")return!0;return e?.action==="findMany"&&typeof t.take==="number"&&Number.isFinite(t.take)&&Math.abs(t.take)<=100}catch{return!1}};`
- );
+ const strictHeader = '"use strict";';
+ if (!source.includes(strictHeader)) {
+ throw new Error(
+ `Unsupported `@prisma/client` react-native strict header shape: ${runtimePath}`
+ );
+ }
+
+ source = source.replace(
+ strictHeader,
+ `${strictHeader}var ${marker}=e=>{try{let t=e?.query?.arguments??{};if(t.distinct!=null)return!1;if(e?.action==="findUnique"||e?.action==="findFirst")return!0;return e?.action==="findMany"&&typeof t.take==="number"&&Number.isFinite(t.take)&&Math.abs(t.take)<=100}catch{return!1}};`
+ );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| source = source.replace( | |
| '"use strict";', | |
| `"use strict";var ${marker}=e=>{try{let t=e?.query?.arguments??{};if(t.distinct!=null)return!1;if(e?.action==="findUnique"||e?.action==="findFirst")return!0;return e?.action==="findMany"&&typeof t.take==="number"&&Number.isFinite(t.take)&&Math.abs(t.take)<=100}catch{return!1}};` | |
| ); | |
| const strictHeader = '"use strict";'; | |
| if (!source.includes(strictHeader)) { | |
| throw new Error( | |
| `Unsupported `@prisma/client` react-native strict header shape: ${runtimePath}` | |
| ); | |
| } | |
| source = source.replace( | |
| strictHeader, | |
| `${strictHeader}var ${marker}=e=>{try{let t=e?.query?.arguments??{};if(t.distinct!=null)return!1;if(e?.action==="findUnique"||e?.action==="findFirst")return!0;return e?.action==="findMany"&&typeof t.take==="number"&&Number.isFinite(t.take)&&Math.abs(t.take)<=100}catch{return!1}};` | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/patch-prisma-runtime.cjs` around lines 19 - 22, The runtime patch in
patch-prisma-runtime.cjs can end up writing code that references
__prismaReactNativeFastRead without having inserted the helper first. Update the
patch flow around the source.replace logic to verify the marker/helper was
actually injected before any later replacements or writeFileSync output, and
treat a missing "use strict"; match as an unsupported runtime shape that should
fail early instead of emitting a broken runtime.
|
Prisma 7 官方已经不再发布 React Native Rust Query Engine,方向改为“WASM Query Compiler + Driver Adapter”。所以正确升级不是重新编译旧 20MB 引擎,而是让你的 fork 变成轻量 JSI SQLite Driver Adapter;这样体积更小,同时底层 SQL 仍可同步直达 C++。 等待我的更新 |
- 使用 Nitro 同步桥连接原生 Query Compiler 与库内 SQLite3 执行器,移除 Expo Modules、expo-sqlite 和相关补丁依赖 - 由本包 postinstall 自动接入官方 prisma-client 生成器,默认无参连接 app.db,统一官方、本包与任意合法 output 的模型和 Client 入口 - 保留 BigInt 无损读写、设备迁移及同步 CRUD,复用官方结果扩展处理计算字段、select 与关联查询 - 精简依赖和生成配置,更新 README 为从 @prisma/client 导入的简短 Provider 示例 - 验证 Release/Hermes 模拟器 16 组运行场景、8 个合法输出与 5 个拒绝边界、重复安装和生成幂等
- 将默认和命名数据库恢复到 iOS Library 目录,保持原 React Native Prisma 的文件路径与无参 API - 保留自定义目录能力,直接读取旧 app.db,由已有迁移机制升级记录结构并保留业务数据 - Release/Hermes 16 组验证通过,包括旧 Library 数据库、命名和自定义目录、BigInt、同步查询与结果扩展
- 使用 SQLite savepoint 兼容查询计划内部事务,保留完整同步模型与结果扩展 - 拒绝旧数组和异步回调,禁止事务结束后继续使用 tx - 简化事务示例并说明默认沿用 Library/app.db
Summary by CodeRabbit
New Features
Bug Fixes
Chores