expo-sqlite 58.0.9 → 58.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/android/build.gradle +6 -2
  3. package/android/src/main/cpp/NativeDatabaseBinding.cpp +11 -8
  4. package/android/src/main/cpp/NativeStatementBinding.cpp +43 -2
  5. package/android/src/main/cpp/NativeStatementBinding.h +3 -0
  6. package/android/src/main/cpp/SQLiteError.h +34 -0
  7. package/android/src/main/java/expo/modules/sqlite/DatabaseConnection.kt +68 -0
  8. package/android/src/main/java/expo/modules/sqlite/NativeDatabase.kt +135 -22
  9. package/android/src/main/java/expo/modules/sqlite/NativeSession.kt +126 -6
  10. package/android/src/main/java/expo/modules/sqlite/NativeStatement.kt +199 -14
  11. package/android/src/main/java/expo/modules/sqlite/NativeStatementBinding.kt +1 -0
  12. package/android/src/main/java/expo/modules/sqlite/SQLRecords.kt +19 -13
  13. package/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt +176 -577
  14. package/android/src/main/java/expo/modules/sqlite/SQLiteOptions.kt +3 -10
  15. package/android/src/main/java/expo/modules/sqlite/SQLiteValues.kt +47 -0
  16. package/build/NativeDatabase.d.ts +2 -2
  17. package/build/SQLiteDatabase.js +9 -3
  18. package/build/SQLiteDatabase.js.map +1 -1
  19. package/dev-plugin-dist/+not-found.html +1 -1
  20. package/dev-plugin-dist/_expo/static/js/web/{__common-9b94dd2fbdbb825a662f42cf8d2077ee.js → __common-8b6d10c7ab64ecfd128d45105ef5590b.js} +51 -48
  21. package/dev-plugin-dist/_expo/static/js/web/{_layout-b2894030c1dfbd95b717a85901b6c271.js → _layout-1da259c4109daa50bd04899675f5d333.js} +23 -23
  22. package/dev-plugin-dist/_expo/static/js/web/{entry-04fdb7d857a65c0ed638ef2d774a4b6e.js → entry-5e24130038c41e25d9a78d08664ef6cb.js} +753 -753
  23. package/dev-plugin-dist/_expo/static/js/web/{index-4bf2da199f699eb47a42074d5e183c07.js → index-17ca77580cae7c249688c43b3b3e0949.js} +1740 -1740
  24. package/dev-plugin-dist/_expo/static/js/web/{worker-d51aa6be89e271e571111274ab8e7f5c.js → worker-cc2e40fb110f53b73733dd7e24d9d8f6.js} +17 -17
  25. package/dev-plugin-dist/_sitemap.html +1 -1
  26. package/dev-plugin-dist/index.html +1 -1
  27. package/expo-module.config.json +0 -1
  28. package/ios/Benchmarks/JavaScriptBenchmarks.swift +65 -0
  29. package/ios/DatabaseChangeEvent.swift +4 -3
  30. package/ios/NativeDatabase.swift +5 -8
  31. package/ios/NativeStatement.swift +168 -5
  32. package/ios/SQLiteBindValue.swift +39 -0
  33. package/ios/SQLiteColumnValue.swift +54 -0
  34. package/ios/SQLiteModule.swift +3 -191
  35. package/ios/SQLiteResult.swift +31 -0
  36. package/ios/Tests/NativeStatementJavaScriptTests.swift +124 -0
  37. package/ios/Tests/NativeStatementTests.swift +122 -0
  38. package/ios/Tests/SQLiteModuleTests.swift +18 -1
  39. package/ios/Tests/test_ErrorReporting.swift +25 -0
  40. package/ios/Tests/test_StatementCleanup.swift +69 -0
  41. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11-sources.jar +0 -0
  42. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11-sources.jar.md5 +1 -0
  43. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11-sources.jar.sha1 +1 -0
  44. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11-sources.jar.sha256 +1 -0
  45. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11-sources.jar.sha512 +1 -0
  46. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.aar +0 -0
  47. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.aar.md5 +1 -0
  48. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.aar.sha1 +1 -0
  49. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.aar.sha256 +1 -0
  50. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.aar.sha512 +1 -0
  51. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{58.0.9/expo.modules.sqlite-58.0.9.module → 58.0.11/expo.modules.sqlite-58.0.11.module} +22 -22
  52. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.module.md5 +1 -0
  53. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.module.sha1 +1 -0
  54. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.module.sha256 +1 -0
  55. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.module.sha512 +1 -0
  56. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/{58.0.9/expo.modules.sqlite-58.0.9.pom → 58.0.11/expo.modules.sqlite-58.0.11.pom} +1 -1
  57. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.pom.md5 +1 -0
  58. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.pom.sha1 +1 -0
  59. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.pom.sha256 +1 -0
  60. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.11/expo.modules.sqlite-58.0.11.pom.sha512 +1 -0
  61. package/package.json +4 -4
  62. package/src/NativeDatabase.ts +2 -2
  63. package/src/SQLiteDatabase.ts +11 -3
  64. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9-sources.jar +0 -0
  65. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9-sources.jar.md5 +0 -1
  66. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9-sources.jar.sha1 +0 -1
  67. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9-sources.jar.sha256 +0 -1
  68. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9-sources.jar.sha512 +0 -1
  69. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.aar +0 -0
  70. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.aar.md5 +0 -1
  71. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.aar.sha1 +0 -1
  72. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.aar.sha256 +0 -1
  73. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.aar.sha512 +0 -1
  74. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.module.md5 +0 -1
  75. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.module.sha1 +0 -1
  76. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.module.sha256 +0 -1
  77. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.module.sha512 +0 -1
  78. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.pom.md5 +0 -1
  79. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.pom.sha1 +0 -1
  80. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.pom.sha256 +0 -1
  81. package/local-maven-repo/host/exp/exponent/expo.modules.sqlite/58.0.9/expo.modules.sqlite-58.0.9.pom.sha512 +0 -1
@@ -314,5 +314,5 @@ input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-web
314
314
  @keyframes r-imtty0{0%{opacity:0;}100%{opacity:1;}}
315
315
  @keyframes r-q67da2{0%{transform:translateX(-100%);}100%{transform:translateX(400%);}}
316
316
  @keyframes r-t2lo5v{0%{opacity:1;}100%{opacity:0;}}</style><script type="module">globalThis.__EXPO_ROUTER_HYDRATE__=true;</script><link rel="preload" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css" as="style">
317
- <link rel="stylesheet" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css"></head><body><div id="root"><div class="css-g5y9jx r-13awgt0"></div></div><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__expo-metro-runtime-8c088df87a31e4e6accd81c554ec290d.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/_layout-b2894030c1dfbd95b717a85901b6c271.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__common-9b94dd2fbdbb825a662f42cf8d2077ee.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/entry-04fdb7d857a65c0ed638ef2d774a4b6e.js" defer></script>
317
+ <link rel="stylesheet" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css"></head><body><div id="root"><div class="css-g5y9jx r-13awgt0"></div></div><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__expo-metro-runtime-8c088df87a31e4e6accd81c554ec290d.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/_layout-1da259c4109daa50bd04899675f5d333.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__common-8b6d10c7ab64ecfd128d45105ef5590b.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/entry-5e24130038c41e25d9a78d08664ef6cb.js" defer></script>
318
318
  </body></html>
@@ -314,5 +314,5 @@ input::-webkit-search-cancel-button,input::-webkit-search-decoration,input::-web
314
314
  @keyframes r-imtty0{0%{opacity:0;}100%{opacity:1;}}
315
315
  @keyframes r-q67da2{0%{transform:translateX(-100%);}100%{transform:translateX(400%);}}
316
316
  @keyframes r-t2lo5v{0%{opacity:1;}100%{opacity:0;}}</style><script type="module">globalThis.__EXPO_ROUTER_HYDRATE__=true;</script><link rel="preload" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css" as="style">
317
- <link rel="stylesheet" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css"></head><body><div id="root"><div class="css-g5y9jx r-13awgt0"><!--$--><!--$--><div class="flex min-h-screen items-center justify-center bg-linear-to-br from-slate-50 to-slate-100 p-4"><div class="rounded-xl border bg-card text-card-foreground shadow w-full max-w-2xl"><div class="flex flex-col space-y-1.5 p-6 text-center"><div class="font-semibold tracking-tight text-3xl">SQLite Database Inspector</div><div class="text-muted-foreground text-base">Upload a database file or connect to your app</div></div><div class="p-6 pt-0"><div dir="ltr" data-orientation="horizontal" class="w-full"><div role="tablist" aria-orientation="horizontal" class="h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground grid w-full grid-cols-2" tabindex="-1" data-orientation="horizontal" style="outline:none"><button type="button" role="tab" aria-selected="true" aria-controls="radix-_R_jer3_-content-devtools" data-state="active" data-disabled="" disabled="" id="radix-_R_jer3_-trigger-devtools" class="inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow" tabindex="-1" data-orientation="horizontal" data-radix-collection-item="">From App </button><button type="button" role="tab" aria-selected="false" aria-controls="radix-_R_jer3_-content-upload" data-state="inactive" id="radix-_R_jer3_-trigger-upload" class="inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow" tabindex="-1" data-orientation="horizontal" data-radix-collection-item="">Upload File</button></div><div data-state="inactive" data-orientation="horizontal" role="tabpanel" aria-labelledby="radix-_R_jer3_-trigger-upload" hidden="" id="radix-_R_jer3_-content-upload" tabindex="0" class="mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"></div><div data-state="active" data-orientation="horizontal" role="tabpanel" aria-labelledby="radix-_R_jer3_-trigger-devtools" id="radix-_R_jer3_-content-devtools" tabindex="0" class="mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2" style="animation-duration:0s"><div class="space-y-4"><div class="flex items-center justify-between"><h3 class="text-sm font-medium">Available Databases</h3><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&amp;_svg]:pointer-events-none [&amp;_svg]:size-4 [&amp;_svg]:shrink-0 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground h-8 rounded-md px-3 text-xs"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw h-4 w-4 mr-2" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg>Refresh</button></div><div class="text-center p-12 rounded-lg border-2 border-dashed border-muted-foreground/25"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-database h-12 w-12 text-muted-foreground mx-auto mb-4" aria-hidden="true"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5V19A9 3 0 0 0 21 19V5"></path><path d="M3 12A9 3 0 0 0 21 12"></path></svg><p class="text-sm text-muted-foreground">No databases found. Make sure your app is using useSQLiteDevTool.</p></div></div></div></div></div></div></div><section aria-label="Notifications alt+T" tabindex="-1" aria-live="polite" aria-relevant="additions text" aria-atomic="false"></section><!--/$--><!--/$--></div></div><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__expo-metro-runtime-8c088df87a31e4e6accd81c554ec290d.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/_layout-b2894030c1dfbd95b717a85901b6c271.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/index-4bf2da199f699eb47a42074d5e183c07.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__common-9b94dd2fbdbb825a662f42cf8d2077ee.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/entry-04fdb7d857a65c0ed638ef2d774a4b6e.js" defer></script>
317
+ <link rel="stylesheet" href="/_expo/plugins/expo-sqlite/_expo/static/css/global-b1bdf830cdbd0ec4238cc5f230f99460.css"></head><body><div id="root"><div class="css-g5y9jx r-13awgt0"><!--$--><!--$--><div class="flex min-h-screen items-center justify-center bg-linear-to-br from-slate-50 to-slate-100 p-4"><div class="rounded-xl border bg-card text-card-foreground shadow w-full max-w-2xl"><div class="flex flex-col space-y-1.5 p-6 text-center"><div class="font-semibold tracking-tight text-3xl">SQLite Database Inspector</div><div class="text-muted-foreground text-base">Upload a database file or connect to your app</div></div><div class="p-6 pt-0"><div dir="ltr" data-orientation="horizontal" class="w-full"><div role="tablist" aria-orientation="horizontal" class="h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground grid w-full grid-cols-2" tabindex="-1" data-orientation="horizontal" style="outline:none"><button type="button" role="tab" aria-selected="true" aria-controls="radix-_R_jer3_-content-devtools" data-state="active" data-disabled="" disabled="" id="radix-_R_jer3_-trigger-devtools" class="inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow" tabindex="-1" data-orientation="horizontal" data-radix-collection-item="">From App </button><button type="button" role="tab" aria-selected="false" aria-controls="radix-_R_jer3_-content-upload" data-state="inactive" id="radix-_R_jer3_-trigger-upload" class="inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow" tabindex="-1" data-orientation="horizontal" data-radix-collection-item="">Upload File</button></div><div data-state="inactive" data-orientation="horizontal" role="tabpanel" aria-labelledby="radix-_R_jer3_-trigger-upload" hidden="" id="radix-_R_jer3_-content-upload" tabindex="0" class="mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"></div><div data-state="active" data-orientation="horizontal" role="tabpanel" aria-labelledby="radix-_R_jer3_-trigger-devtools" id="radix-_R_jer3_-content-devtools" tabindex="0" class="mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2" style="animation-duration:0s"><div class="space-y-4"><div class="flex items-center justify-between"><h3 class="text-sm font-medium">Available Databases</h3><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&amp;_svg]:pointer-events-none [&amp;_svg]:size-4 [&amp;_svg]:shrink-0 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground h-8 rounded-md px-3 text-xs"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw h-4 w-4 mr-2" aria-hidden="true"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path><path d="M8 16H3v5"></path></svg>Refresh</button></div><div class="text-center p-12 rounded-lg border-2 border-dashed border-muted-foreground/25"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-database h-12 w-12 text-muted-foreground mx-auto mb-4" aria-hidden="true"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M3 5V19A9 3 0 0 0 21 19V5"></path><path d="M3 12A9 3 0 0 0 21 12"></path></svg><p class="text-sm text-muted-foreground">No databases found. Make sure your app is using useSQLiteDevTool.</p></div></div></div></div></div></div></div><section aria-label="Notifications alt+T" tabindex="-1" aria-live="polite" aria-relevant="additions text" aria-atomic="false"></section><!--/$--><!--/$--></div></div><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__expo-metro-runtime-8c088df87a31e4e6accd81c554ec290d.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/_layout-1da259c4109daa50bd04899675f5d333.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/index-17ca77580cae7c249688c43b3b3e0949.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/__common-8b6d10c7ab64ecfd128d45105ef5590b.js" defer></script><script src="/_expo/plugins/expo-sqlite/_expo/static/js/web/entry-5e24130038c41e25d9a78d08664ef6cb.js" defer></script>
318
318
  </body></html>
@@ -4,7 +4,6 @@
4
4
  "modules": ["SQLiteModule"]
5
5
  },
6
6
  "android": {
7
- "modules": ["expo.modules.sqlite.SQLiteModule"],
8
7
  "shouldUsePublicationScriptPath": "android/shouldUsePublication.groovy",
9
8
  "publication": {
10
9
  "groupId": "host.exp.exponent",
@@ -177,6 +177,71 @@ extension Benchmarks {
177
177
  }
178
178
  }
179
179
 
180
+ /// `SQLiteDatabase.runSync(source, { $name: value })`: named parameters resolve their index through
181
+ /// `sqlite3_bind_parameter_index` instead of the array position.
182
+ @Test
183
+ func `JS: insert with named parameters`() async throws {
184
+ try await sqliteBenchmarkCase { appContext in
185
+ let runtime = try prepareRuntime(appContext)
186
+ _ = try runtime.eval(
187
+ """
188
+ var insert = new NativeStatement();
189
+ db.prepareSync(insert, 'INSERT INTO t (int_value, real_value, text_value, null_value) VALUES ($i, $r, $t, $n)');
190
+ """
191
+ )
192
+ let run = try driver(
193
+ runtime,
194
+ "insert.runSync(db, { $i: i, $r: 1.5, $t: 'row', $n: null }, {}, false);"
195
+ )
196
+ try benchmark("JS: runSync insert with 4 named parameters", runtime: runtime) { iterations in
197
+ _ = try run.call(arguments: iterations)
198
+ }
199
+ }
200
+ }
201
+
202
+ /// `SQLiteDatabase.runSync(source, [blob])`: the blob goes through the separate blob parameters.
203
+ @Test
204
+ func `JS: insert with a blob parameter`() async throws {
205
+ try await sqliteBenchmarkCase { appContext in
206
+ let runtime = try prepareRuntime(appContext)
207
+ _ = try runtime.eval(
208
+ """
209
+ var insert = new NativeStatement();
210
+ db.prepareSync(insert, 'INSERT INTO blobs (data) VALUES (?)');
211
+ var blob = new Uint8Array(1024);
212
+ """
213
+ )
214
+ let run = try driver(runtime, "insert.runSync(db, {}, { 0: blob }, true);")
215
+ try benchmark("JS: runSync insert with a 1 KiB blob parameter", runtime: runtime) { iterations in
216
+ _ = try run.call(arguments: iterations)
217
+ }
218
+ }
219
+ }
220
+
221
+ /// `SQLiteStatement.executeSync(...)` iterated row by row: one native call per row.
222
+ @Test
223
+ func `JS: step through 100 rows`() async throws {
224
+ try await sqliteBenchmarkCase { appContext in
225
+ let runtime = try prepareRuntime(appContext)
226
+ _ = try runtime.eval(
227
+ """
228
+ var cursor = new NativeStatement();
229
+ db.prepareSync(cursor, 'SELECT \(BenchmarkSchema.selectColumns) FROM t WHERE id <= 100');
230
+ """
231
+ )
232
+ let run = try driver(
233
+ runtime,
234
+ """
235
+ cursor.resetSync(db);
236
+ while (cursor.stepSync(db) != null) {}
237
+ """
238
+ )
239
+ try benchmark("JS: stepSync through 100 rows", runtime: runtime) { iterations in
240
+ _ = try run.call(arguments: iterations)
241
+ }
242
+ }
243
+ }
244
+
180
245
  @Test
181
246
  func `JS: column names of a prepared statement`() async throws {
182
247
  try await sqliteBenchmarkCase { appContext in
@@ -8,8 +8,9 @@ struct DatabaseChangeEvent {
8
8
  var databaseName: String
9
9
  var databaseFilePath: String
10
10
  var tableName: String
11
- // `Int` rather than SQLite's `Int64`: a 64-bit integer encodes as a JavaScript BigInt, and JavaScript
12
- // reads the row id as a number.
13
- var rowId: Int
11
+ // A `Double` rather than SQLite's `Int64` or an `Int`: JavaScript reads the row id as a number, an
12
+ // `Int64` would encode as a BigInt, and an `Int` throws above 2^53, which would drop the event. Above
13
+ // 2^53 it loses precision, like integer columns do.
14
+ var rowId: Double
14
15
  var typeId: SQLAction
15
16
  }
@@ -144,8 +144,11 @@ final class NativeDatabase: SharedObject, @unchecked Sendable {
144
144
  try statement.ensureNotFinalized()
145
145
  try ensureOpen()
146
146
  let sourceString = source.cString(using: .utf8)
147
- if exsqlite3_prepare_v2(pointer, sourceString, -1, &statement.pointer, nil) != SQLITE_OK {
148
- throw SQLiteErrorException(lastErrorMessage())
147
+ let result = sqliteResult(for: pointer) {
148
+ exsqlite3_prepare_v2(pointer, sourceString, -1, &statement.pointer, nil)
149
+ }
150
+ if let message = result.message {
151
+ throw SQLiteErrorException(message)
149
152
  }
150
153
  statements.append(statement)
151
154
  }
@@ -172,12 +175,6 @@ final class NativeDatabase: SharedObject, @unchecked Sendable {
172
175
  }
173
176
  }
174
177
 
175
- internal func sqliteErrorMessage(for db: OpaquePointer?) -> String {
176
- let code = exsqlite3_errcode(db)
177
- let message = String(cString: exsqlite3_errmsg(db), encoding: .utf8) ?? ""
178
- return "Error code \(code): \(message)"
179
- }
180
-
181
178
  // `==` lives in an extension: an operator declared inside a type that carries a member-attribute macro
182
179
  // is seen twice by the compiler and fails the `Equatable` conformance check.
183
180
  // swiftlint:disable:next no_grouping_extension
@@ -57,6 +57,46 @@ final class NativeStatement: SharedObject, @unchecked Sendable {
57
57
  try finalize(database: database)
58
58
  }
59
59
 
60
+ @JS(.concurrent)
61
+ func runAsync(
62
+ database: NativeDatabase,
63
+ bindParams: [String: SQLiteBindValue?],
64
+ bindBlobParams: [String: ArrayBuffer],
65
+ shouldPassAsArray: Bool
66
+ ) async throws -> SQLiteRunResult {
67
+ return try run(database: database, bindParams: bindParams, bindBlobParams: bindBlobParams, shouldPassAsArray: shouldPassAsArray)
68
+ }
69
+
70
+ @JS
71
+ func runSync(
72
+ database: NativeDatabase,
73
+ bindParams: [String: SQLiteBindValue?],
74
+ bindBlobParams: [String: ArrayBuffer],
75
+ shouldPassAsArray: Bool
76
+ ) throws -> SQLiteRunResult {
77
+ return try run(database: database, bindParams: bindParams, bindBlobParams: bindBlobParams, shouldPassAsArray: shouldPassAsArray)
78
+ }
79
+
80
+ @JS(.concurrent)
81
+ func stepAsync(database: NativeDatabase) async throws -> [SQLiteColumnValue?]? {
82
+ return try step(database: database)
83
+ }
84
+
85
+ @JS
86
+ func stepSync(database: NativeDatabase) throws -> [SQLiteColumnValue?]? {
87
+ return try step(database: database)
88
+ }
89
+
90
+ @JS(.concurrent)
91
+ func getAllAsync(database: NativeDatabase) async throws -> [[SQLiteColumnValue?]] {
92
+ return try getAll(database: database)
93
+ }
94
+
95
+ @JS
96
+ func getAllSync(database: NativeDatabase) throws -> [[SQLiteColumnValue?]] {
97
+ return try getAll(database: database)
98
+ }
99
+
60
100
  // MARK: - Implementation shared by the sync and async members
61
101
 
62
102
  private func reset(database: NativeDatabase) throws {
@@ -64,8 +104,9 @@ final class NativeStatement: SharedObject, @unchecked Sendable {
64
104
  try ensureNotFinalized()
65
105
  try database.ensureOpen()
66
106
 
67
- if exsqlite3_reset(pointer) != SQLITE_OK {
68
- throw SQLiteErrorException(database.lastErrorMessage())
107
+ let result = sqliteResult(for: database.pointer) { exsqlite3_reset(pointer) }
108
+ if let message = result.message {
109
+ throw SQLiteErrorException(message)
69
110
  }
70
111
  }
71
112
  }
@@ -89,16 +130,138 @@ final class NativeStatement: SharedObject, @unchecked Sendable {
89
130
  try ensureNotFinalized()
90
131
  try database.ensureOpen()
91
132
 
92
- let ret = exsqlite3_finalize(pointer)
133
+ let result = sqliteResult(for: database.pointer) { exsqlite3_finalize(pointer) }
93
134
  // SQLite destroys the statement even when returning an earlier execution error.
94
135
  isFinalized = true
95
136
  pointer = nil
96
137
  database.statements.removeAll { $0 === self }
97
- if ret != SQLITE_OK {
98
- throw SQLiteErrorException(database.lastErrorMessage())
138
+ if let message = result.message {
139
+ throw SQLiteErrorException(message)
99
140
  }
100
141
  }
101
142
  }
143
+
144
+ private func run(
145
+ database: NativeDatabase,
146
+ bindParams: [String: SQLiteBindValue?],
147
+ bindBlobParams: [String: ArrayBuffer],
148
+ shouldPassAsArray: Bool
149
+ ) throws -> SQLiteRunResult {
150
+ return try lock.withLock { _ in
151
+ try ensureNotFinalized()
152
+ try database.ensureOpen()
153
+
154
+ exsqlite3_reset(pointer)
155
+ exsqlite3_clear_bindings(pointer)
156
+ for (key, param) in bindParams {
157
+ let index = try bindParamIndex(for: key, shouldPassAsArray: shouldPassAsArray)
158
+ guard index > 0 else {
159
+ continue
160
+ }
161
+ if let param {
162
+ param.bind(to: pointer, at: index)
163
+ } else {
164
+ exsqlite3_bind_null(pointer, index)
165
+ }
166
+ }
167
+ for (key, param) in bindBlobParams {
168
+ let index = try bindParamIndex(for: key, shouldPassAsArray: shouldPassAsArray)
169
+ if index > 0 {
170
+ SQLiteBindValue.blob(param).bind(to: pointer, at: index)
171
+ }
172
+ }
173
+
174
+ let result = sqliteResult(for: database.pointer) { exsqlite3_step(pointer) }
175
+ let ret = result.code
176
+ if let message = result.message {
177
+ throw SQLiteErrorException(message)
178
+ }
179
+ return SQLiteRunResult(
180
+ lastInsertRowId: Double(exsqlite3_last_insert_rowid(database.pointer)),
181
+ changes: Int(exsqlite3_changes(database.pointer)),
182
+ firstRowValues: ret == SQLITE_ROW ? try columnValues() : []
183
+ )
184
+ }
185
+ }
186
+
187
+ private func step(database: NativeDatabase) throws -> [SQLiteColumnValue?]? {
188
+ return try lock.withLock { _ in
189
+ try ensureNotFinalized()
190
+ try database.ensureOpen()
191
+
192
+ let result = sqliteResult(for: database.pointer) { exsqlite3_step(pointer) }
193
+ let ret = result.code
194
+ if ret == SQLITE_ROW {
195
+ return try columnValues()
196
+ }
197
+ if let message = result.message {
198
+ throw SQLiteErrorException(message)
199
+ }
200
+ return nil
201
+ }
202
+ }
203
+
204
+ private func getAll(database: NativeDatabase) throws -> [[SQLiteColumnValue?]] {
205
+ return try lock.withLock { _ in
206
+ try ensureNotFinalized()
207
+ try database.ensureOpen()
208
+
209
+ var rows: [[SQLiteColumnValue?]] = []
210
+ while true {
211
+ let result = sqliteResult(for: database.pointer) { exsqlite3_step(pointer) }
212
+ let ret = result.code
213
+ if ret == SQLITE_ROW {
214
+ rows.append(try columnValues())
215
+ continue
216
+ }
217
+ if ret == SQLITE_DONE {
218
+ break
219
+ }
220
+ if let message = result.message {
221
+ throw SQLiteErrorException(message)
222
+ }
223
+ throw SQLiteErrorException("Error code \(result.code)")
224
+ }
225
+ return rows
226
+ }
227
+ }
228
+
229
+ /// The values of the current row. Call it inside `lock`, after a step that returned `SQLITE_ROW`.
230
+ private func columnValues() throws -> [SQLiteColumnValue?] {
231
+ let columnCount = exsqlite3_column_count(pointer)
232
+ var values: [SQLiteColumnValue?] = []
233
+ values.reserveCapacity(Int(columnCount))
234
+ for index in 0..<columnCount {
235
+ values.append(try SQLiteColumnValue.read(from: pointer, column: index))
236
+ }
237
+ return values
238
+ }
239
+
240
+ /// The 1-based SQLite index of a bind parameter: an array position for positional parameters, or the
241
+ /// index of the named parameter otherwise. Zero means the statement has no such parameter.
242
+ private func bindParamIndex(for key: String, shouldPassAsArray: Bool) throws -> Int32 {
243
+ if shouldPassAsArray {
244
+ guard let position = Int32(key) else {
245
+ throw InvalidBindParameterException()
246
+ }
247
+ return position + 1
248
+ }
249
+ return exsqlite3_bind_parameter_index(pointer, key)
250
+ }
251
+ }
252
+
253
+ /// The result of `NativeStatement.run`: the effect of the statement and the values of the first row
254
+ /// it returned, if any.
255
+ @Record
256
+ struct SQLiteRunResult {
257
+ // A `Double` rather than SQLite's `Int64` or an `Int`: JavaScript reads the row id as a number, an
258
+ // `Int64` would encode as a BigInt, and an `Int` throws above 2^53. The row id is connection-wide, so a
259
+ // throw would also fail every later run on the connection. Above 2^53 it loses precision, like integer
260
+ // columns do.
261
+ var lastInsertRowId: Double
262
+ // `sqlite3_changes` returns a 32-bit count, which always fits a JavaScript number.
263
+ var changes: Int
264
+ var firstRowValues: [SQLiteColumnValue?]
102
265
  }
103
266
 
104
267
  // `==` lives in an extension: an operator declared inside a type that carries a member-attribute macro
@@ -0,0 +1,39 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import ExpoModulesCore
4
+
5
+ /// A bind parameter as it comes from JavaScript: `number | string | boolean | bigint | ArrayBuffer`.
6
+ /// `null` arrives as `nil` of the optional around it.
7
+ ///
8
+ /// A union decodes its cases in declaration order and the first match wins, so `double` goes first:
9
+ /// the `Int64` decode accepts any number and rounds it, which would turn `1.5` into `2`. Ordered after
10
+ /// `double`, `integer` only matches a `bigint`.
11
+ @Union
12
+ enum SQLiteBindValue: Sendable {
13
+ case double(Double)
14
+ case text(String)
15
+ case boolean(Bool)
16
+ case integer(Int64)
17
+ case blob(ArrayBuffer)
18
+
19
+ /// Binds the value to the parameter at `index` of `statement`.
20
+ @inline(__always)
21
+ func bind(to statement: OpaquePointer?, at index: Int32) {
22
+ switch self {
23
+ case .double(let value):
24
+ exsqlite3_bind_double(statement, index, value)
25
+ case .text(let value):
26
+ exsqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)
27
+ case .boolean(let value):
28
+ exsqlite3_bind_int(statement, index, value ? 1 : 0)
29
+ case .integer(let value):
30
+ exsqlite3_bind_int64(statement, index, value)
31
+ case .blob(let value):
32
+ _ = value.withUnsafeBytes {
33
+ exsqlite3_bind_blob(statement, index, $0.baseAddress, Int32(value.byteLength), SQLITE_TRANSIENT)
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ private let SQLITE_TRANSIENT = unsafeBitCast(OpaquePointer(bitPattern: -1), to: sqlite3_destructor_type.self)
@@ -0,0 +1,54 @@
1
+ // Copyright 2015-present 650 Industries. All rights reserved.
2
+
3
+ import ExpoModulesCore
4
+
5
+ /// A column value as it goes to JavaScript: `number | string | ArrayBuffer`. `NULL` goes as `nil` of
6
+ /// the optional around it.
7
+ ///
8
+ /// `INTEGER` columns are read as `double`, so they reach JavaScript as a number, not a `bigint`. That
9
+ /// loses precision above 2^53, as the type-erased conversion did before.
10
+ @Union
11
+ enum SQLiteColumnValue: Sendable, Equatable {
12
+ case double(Double)
13
+ case text(String)
14
+ case blob(ArrayBuffer)
15
+
16
+ /// Reads the value of the column at `index` in the current row of `statement`, or `nil` for `NULL`.
17
+ @inline(__always)
18
+ static func read(from statement: OpaquePointer?, column index: Int32) throws -> SQLiteColumnValue? {
19
+ switch exsqlite3_column_type(statement, index) {
20
+ case SQLITE_INTEGER:
21
+ return .double(Double(exsqlite3_column_int64(statement, index)))
22
+ case SQLITE_FLOAT:
23
+ return .double(exsqlite3_column_double(statement, index))
24
+ case SQLITE_TEXT:
25
+ guard let text = exsqlite3_column_text(statement, index) else {
26
+ throw InvalidConvertibleException("Null text")
27
+ }
28
+ return .text(String(cString: text))
29
+ case SQLITE_BLOB:
30
+ guard let blob = exsqlite3_column_blob(statement, index) else {
31
+ return .blob(ArrayBuffer(size: 0))
32
+ }
33
+ let size = exsqlite3_column_bytes(statement, index)
34
+ return .blob(ArrayBuffer.copy(of: blob, count: Int(size)))
35
+ case SQLITE_NULL:
36
+ return nil
37
+ case let type:
38
+ throw InvalidConvertibleException("Unsupported column type: \(type)")
39
+ }
40
+ }
41
+
42
+ static func == (lhs: SQLiteColumnValue, rhs: SQLiteColumnValue) -> Bool {
43
+ switch (lhs, rhs) {
44
+ case let (.double(lhs), .double(rhs)):
45
+ return lhs == rhs
46
+ case let (.text(lhs), .text(rhs)):
47
+ return lhs == rhs
48
+ case let (.blob(lhs), .blob(rhs)):
49
+ return lhs.withUnsafeBytes { lhs in rhs.withUnsafeBytes { rhs in lhs.elementsEqual(rhs) } }
50
+ default:
51
+ return false
52
+ }
53
+ }
54
+ }