@capacitor-community/sqlite 3.3.3 → 3.4.0-1
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 +15 -14
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +5 -3
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java +19 -0
- package/ios/Plugin/Database.swift +13 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/dw/@capacitor-community/sqlite?style=flat-square" /></a>
|
|
17
17
|
<a href="https://www.npmjs.com/package/@capacitor-community/sqlite"><img src="https://img.shields.io/npm/v/@capacitor-community/sqlite?style=flat-square" /></a>
|
|
18
18
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
19
|
-
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-
|
|
19
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-13-orange?style=flat-square" /></a>
|
|
20
20
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
21
21
|
</p>
|
|
22
22
|
|
|
@@ -116,11 +116,11 @@ npx cap sync @capacitor-community/electron
|
|
|
116
116
|
|
|
117
117
|
#### For Angular framework
|
|
118
118
|
|
|
119
|
-
- copy manually the file `sql-wasm.wasm` from `
|
|
119
|
+
- copy manually the file `sql-wasm.wasm` from `node_modules/sql.js/dist/sql-wasm.wasm` to the `src/assets` folder of YOUR_APP
|
|
120
120
|
|
|
121
121
|
#### For Vue & React frameworks
|
|
122
122
|
|
|
123
|
-
- copy manually the file `sql-wasm.wasm` from `
|
|
123
|
+
- copy manually the file `sql-wasm.wasm` from `node_modules/sql.js/dist/sql-wasm.wasm` to the `public/assets` folder of YOUR_APP
|
|
124
124
|
|
|
125
125
|
### IOS
|
|
126
126
|
|
|
@@ -325,17 +325,18 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
325
325
|
<table>
|
|
326
326
|
<tr>
|
|
327
327
|
<td align="center"><a href="https://github.com/jepiqueau"><img src="https://avatars3.githubusercontent.com/u/16580653?v=4" width="100px;" alt=""/><br /><sub><b>Jean Pierre Quéau</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td>
|
|
328
|
-
<td align="center"><a href="https://github.com/paulantoine2"><img src="https://avatars0.githubusercontent.com/u/22882943?s=64&v=4" width="100px;" alt=""/><br /><sub><b>Paul Antoine</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
329
|
-
<td align="center"><a href="https://github.com/karyfars"><img src="https://avatars2.githubusercontent.com/u/303016?s=60&u=1ce232ae3c22eac7b0b4778e46fe079939c39b40&v=4" width="100px;" alt=""/><br /><sub><b>Karyfars</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
330
|
-
<td align="center"><a href="https://github.com/chriswep"><img src="https://avatars2.githubusercontent.com/u/1055809?s=400&u=e555940f143da8be255743028d6838cb5c020b44&v=4" width="100px;" alt=""/><br /><sub><b>Chriswep</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
331
|
-
<td align="center"><a href="https://github.com/nirajhinge"><img src="https://avatars.githubusercontent.com/u/54309996?v=4" width="100px;" alt=""/><br /><sub><b>Nirajhinge</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
332
|
-
<td align="center"><a href="https://github.com/digaus"><img src="https://avatars.githubusercontent.com/u/15358538?v=4" width="100px;" alt=""/><br /><sub><b>Dirk Gausmann</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
333
|
-
<td align="center"><a href="https://github.com/IT-MikeS"><img src="https://avatars.githubusercontent.com/u/20338451?v=4" width="100px;" alt=""/><br /><sub><b>Mike Summerfeldt</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
334
|
-
<td align="center"><a href="https://github.com/peakcool"><img src="https://avatars.githubusercontent.com/u/14804014?v=4" width="100px;" alt=""/><br /><sub><b>Peakcool</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
335
|
-
<td align="center"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4" width="100px;" alt=""/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
336
|
-
<td align="center"><a href="https://github.com/robingenz"><img src="https://avatars.githubusercontent.com/u/13857929?v=4" width="100px;" alt=""/><br /><sub><b>Robin Genz</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
337
|
-
<td align="center"><a href="https://github.com/dewald-els"><img src="https://avatars.githubusercontent.com/u/10051247?v=4" width="100px;" alt=""/><br /><sub><b>Dewald Els</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
338
|
-
<td align="center"><a href="https://github.com/joewoodhouse"><img src="https://avatars.githubusercontent.com/u/3168135?v=4" width="100px;" alt=""/><br /><sub><b>Joe Woodhouse</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=
|
|
328
|
+
<td align="center"><a href="https://github.com/paulantoine2"><img src="https://avatars0.githubusercontent.com/u/22882943?s=64&v=4" width="100px;" alt=""/><br /><sub><b>Paul Antoine</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=paulantoine2" title="Code">💻</a></td>
|
|
329
|
+
<td align="center"><a href="https://github.com/karyfars"><img src="https://avatars2.githubusercontent.com/u/303016?s=60&u=1ce232ae3c22eac7b0b4778e46fe079939c39b40&v=4" width="100px;" alt=""/><br /><sub><b>Karyfars</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=karyfars" title="Code">💻</a></td>
|
|
330
|
+
<td align="center"><a href="https://github.com/chriswep"><img src="https://avatars2.githubusercontent.com/u/1055809?s=400&u=e555940f143da8be255743028d6838cb5c020b44&v=4" width="100px;" alt=""/><br /><sub><b>Chriswep</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=chriswep" title="Documentation">📖</a></td>
|
|
331
|
+
<td align="center"><a href="https://github.com/nirajhinge"><img src="https://avatars.githubusercontent.com/u/54309996?v=4" width="100px;" alt=""/><br /><sub><b>Nirajhinge</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=nirajhinge" title="Code">💻</a></td>
|
|
332
|
+
<td align="center"><a href="https://github.com/digaus"><img src="https://avatars.githubusercontent.com/u/15358538?v=4" width="100px;" alt=""/><br /><sub><b>Dirk Gausmann</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=digaus" title="Code">💻</a></td>
|
|
333
|
+
<td align="center"><a href="https://github.com/IT-MikeS"><img src="https://avatars.githubusercontent.com/u/20338451?v=4" width="100px;" alt=""/><br /><sub><b>Mike Summerfeldt</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=IT-MikeS" title="Code">💻</a></td>
|
|
334
|
+
<td align="center"><a href="https://github.com/peakcool"><img src="https://avatars.githubusercontent.com/u/14804014?v=4" width="100px;" alt=""/><br /><sub><b>Peakcool</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=peakcool" title="Code">💻</a></td>
|
|
335
|
+
<td align="center"><a href="https://github.com/gion-andri"><img src="https://avatars.githubusercontent.com/u/540998?v=4" width="100px;" alt=""/><br /><sub><b>Gion-Andri Cantieni</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=gion-andri" title="Documentation">📖</a></td>
|
|
336
|
+
<td align="center"><a href="https://github.com/robingenz"><img src="https://avatars.githubusercontent.com/u/13857929?v=4" width="100px;" alt=""/><br /><sub><b>Robin Genz</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=robingenz" title="Documentation">📖</a></td>
|
|
337
|
+
<td align="center"><a href="https://github.com/dewald-els"><img src="https://avatars.githubusercontent.com/u/10051247?v=4" width="100px;" alt=""/><br /><sub><b>Dewald Els</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=dewald-els" title="Code">💻</a></td>
|
|
338
|
+
<td align="center"><a href="https://github.com/joewoodhouse"><img src="https://avatars.githubusercontent.com/u/3168135?v=4" width="100px;" alt=""/><br /><sub><b>Joe Woodhouse</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=joewoodhouse" title="Documentation">📖</a></td> </tr>
|
|
339
|
+
<td align="center"><a href="https://github.com/ptasheq"><img src="https://avatars.githubusercontent.com/u/3025106?v=4" width="100px;" alt=""/><br /><sub><b>Ptasheq</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=ptasheq" title="Documentation">📖</a></td> </tr>
|
|
339
340
|
</table>
|
|
340
341
|
|
|
341
342
|
<!-- markdownlint-enable -->
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java
CHANGED
|
@@ -940,7 +940,7 @@ public class CapacitorSQLitePlugin extends Plugin {
|
|
|
940
940
|
rHandler.retResult(call, res, null);
|
|
941
941
|
return;
|
|
942
942
|
} catch (Exception e) {
|
|
943
|
-
String msg = "
|
|
943
|
+
String msg = "IsJsonValid: " + e.getMessage();
|
|
944
944
|
rHandler.retResult(call, false, msg);
|
|
945
945
|
return;
|
|
946
946
|
}
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java
CHANGED
|
@@ -371,7 +371,8 @@ public class Database {
|
|
|
371
371
|
}
|
|
372
372
|
if (lastId == -1) break;
|
|
373
373
|
}
|
|
374
|
-
|
|
374
|
+
changes = _uSqlite.dbChanges(_db) - initChanges;
|
|
375
|
+
if (changes >= 0) {
|
|
375
376
|
if (transaction) _db.setTransactionSuccessful();
|
|
376
377
|
changes = _uSqlite.dbChanges(_db) - initChanges;
|
|
377
378
|
retObj.put("changes", changes);
|
|
@@ -457,10 +458,11 @@ public class Database {
|
|
|
457
458
|
SimpleSQLiteQuery.bind(stmt, valObj);
|
|
458
459
|
}
|
|
459
460
|
if (stmtType.equals("INSERT")) {
|
|
460
|
-
|
|
461
|
+
stmt.executeInsert();
|
|
461
462
|
} else {
|
|
462
|
-
|
|
463
|
+
stmt.executeUpdateDelete();
|
|
463
464
|
}
|
|
465
|
+
return _uSqlite.dbLastId(_db);
|
|
464
466
|
} catch (IllegalStateException e) {
|
|
465
467
|
throw new Exception(e.getMessage());
|
|
466
468
|
} catch (IllegalArgumentException e) {
|
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java
CHANGED
|
@@ -33,6 +33,25 @@ public class UtilsSQLite {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
public long dbLastId(SupportSQLiteDatabase db) {
|
|
37
|
+
String SELECT_CHANGE = "SELECT last_insert_rowid()";
|
|
38
|
+
Boolean success = true;
|
|
39
|
+
long ret = Long.valueOf(-1);
|
|
40
|
+
try {
|
|
41
|
+
Cursor cursor = (Cursor) db.query(SELECT_CHANGE, null);
|
|
42
|
+
if (cursor != null) {
|
|
43
|
+
if (cursor.moveToFirst()) {
|
|
44
|
+
ret = Long.parseLong(cursor.getString(0));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
cursor.close();
|
|
48
|
+
} catch (Exception e) {
|
|
49
|
+
Log.d(TAG, "Error: dbLastId failed: ", e);
|
|
50
|
+
} finally {
|
|
51
|
+
return ret;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
public String[] getStatementsArray(String statements) {
|
|
37
56
|
statements.replace("end;", "END;");
|
|
38
57
|
// split for each statement
|
|
@@ -264,6 +264,16 @@ class Database {
|
|
|
264
264
|
throw DatabaseError.executeSQL(
|
|
265
265
|
message: "Failed in executeSQL : \(msg)" )
|
|
266
266
|
}
|
|
267
|
+
} else {
|
|
268
|
+
if transaction {
|
|
269
|
+
do {
|
|
270
|
+
try UtilsSQLCipher
|
|
271
|
+
.rollbackTransaction(mDB: self)
|
|
272
|
+
} catch UtilsSQLCipherError
|
|
273
|
+
.rollbackTransaction(let message) {
|
|
274
|
+
msg.append(" rollback: \(message)")
|
|
275
|
+
}
|
|
276
|
+
}
|
|
267
277
|
}
|
|
268
278
|
return changes
|
|
269
279
|
}
|
|
@@ -310,7 +320,7 @@ class Database {
|
|
|
310
320
|
msg.append(" \(message)")
|
|
311
321
|
throw DatabaseError.execSet(message: msg )
|
|
312
322
|
}
|
|
313
|
-
if changes
|
|
323
|
+
if changes >= 0 && transaction {
|
|
314
324
|
// commit the transaction
|
|
315
325
|
do {
|
|
316
326
|
try UtilsSQLCipher.commitTransaction(mDB: self)
|
|
@@ -321,6 +331,7 @@ class Database {
|
|
|
321
331
|
}
|
|
322
332
|
return changesDict
|
|
323
333
|
}
|
|
334
|
+
// swiftlint:enable function_body_length
|
|
324
335
|
|
|
325
336
|
// MARK: - RunSQL
|
|
326
337
|
|
|
@@ -368,8 +379,8 @@ class Database {
|
|
|
368
379
|
throw DatabaseError.runSQL(message: msg )
|
|
369
380
|
}
|
|
370
381
|
}
|
|
371
|
-
changes = UtilsSQLCipher.dbChanges(mDB: mDb) - initChanges
|
|
372
382
|
}
|
|
383
|
+
changes = UtilsSQLCipher.dbChanges(mDB: mDb) - initChanges
|
|
373
384
|
let result: [String: Int64] = ["changes": Int64(changes),
|
|
374
385
|
"lastId": lastId]
|
|
375
386
|
return result
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-1",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@capacitor/android": "^3.
|
|
59
|
-
"@capacitor/core": "3.
|
|
60
|
-
"@capacitor/docgen": "^0.
|
|
61
|
-
"@capacitor/ios": "^3.
|
|
58
|
+
"@capacitor/android": "^3.4.0",
|
|
59
|
+
"@capacitor/core": "^3.4.0",
|
|
60
|
+
"@capacitor/docgen": "^0.1.1",
|
|
61
|
+
"@capacitor/ios": "^3.4.0",
|
|
62
62
|
"@ionic/eslint-config": "^0.3.0",
|
|
63
63
|
"@ionic/prettier-config": "^1.0.1",
|
|
64
64
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typescript": "~4.0.5"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@capacitor/core": "^3.
|
|
77
|
+
"@capacitor/core": "^3.4.0"
|
|
78
78
|
},
|
|
79
79
|
"prettier": "@ionic/prettier-config",
|
|
80
80
|
"swiftlint": "@ionic/swiftlint-config",
|