expo-sqlite-mock 3.0.1 → 3.0.2

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.
package/README.md CHANGED
@@ -7,9 +7,9 @@ Use [expo-sqlite](https://docs.expo.dev/versions/latest/sdk/sqlite/) with jest.
7
7
 
8
8
  ## Notice
9
9
 
10
- - **~3.0.0** is for expo-sqlite ~53.
11
- - **~2.0.0** is for expo-sqlite ~52.
12
- - **~1.0.0** is for expo-sqlite ~51.
10
+ - **^3.0.0** is for expo-sqlite >=53.
11
+ - **^2.0.0** is for expo-sqlite ~52.
12
+ - **^1.0.0** is for expo-sqlite ~51.
13
13
 
14
14
  ## Usage
15
15
 
@@ -53,6 +53,9 @@ it("test", async () => {
53
53
 
54
54
  ## Changelog
55
55
 
56
+ - **3.0.2**
57
+ - Constraint error handling.
58
+
56
59
  - **3.0.0**
57
60
  - Compatible with expo-sqlite ~15 and expo ~53.
58
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-sqlite-mock",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/zfben/expo-sqlite-mock",
6
6
  "repository": {
@@ -100,10 +100,21 @@ class NativeStatement {
100
100
  bindParams: SQLiteBindPrimitiveParams,
101
101
  bindBlobParams: SQLiteBindBlobParams,
102
102
  shouldPassAsArray: boolean
103
- ): Promise<SQLiteRunResult & { firstRowValues: SQLiteColumnValues }> =>
104
- this._run(
105
- normalizeSQLite3Args(bindParams, bindBlobParams, shouldPassAsArray)
106
- )
103
+ ): Promise<SQLiteRunResult & { firstRowValues: SQLiteColumnValues }> => {
104
+ try {
105
+ return await this._run(
106
+ normalizeSQLite3Args(bindParams, bindBlobParams, shouldPassAsArray)
107
+ )
108
+ } catch (error) {
109
+ if (error && typeof error === 'object' && 'code' in error) {
110
+ const enhancedError = new Error(error.message || error.code)
111
+ Object.assign(enhancedError, { code: error.code })
112
+ throw enhancedError
113
+ }
114
+
115
+ throw error
116
+ }
117
+ }
107
118
  public stepAsync = (_database: NativeDatabase): Promise<any> => {
108
119
  if (this.iterator == null) {
109
120
  this.iterator = this.sqlite3Stmt.iterate()