@capacitor-community/sqlite 3.3.3-4 → 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 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-11-orange?style=flat-square" /></a>
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
 
@@ -80,6 +80,12 @@ The test has been achieved on:
80
80
 
81
81
  - a [Ionic/Vue app](https://github.com/jepiqueau/vue-sqlite-app-starter)
82
82
 
83
+ - a [React Vite app](https://github.com/jepiqueau/react-vite-sqlite-app)
84
+
85
+ - a [Vue Vite app](https://github.com/jepiqueau/vuevite-app)
86
+
87
+ - a [Vue TypeORM app](https://github.com/jepiqueau/vue-typeorm-app)
88
+
83
89
 
84
90
  ## Browser Support
85
91
 
@@ -110,11 +116,11 @@ npx cap sync @capacitor-community/electron
110
116
 
111
117
  #### For Angular framework
112
118
 
113
- - copy manually the file `sql-wasm.wasm` from `nodes_modules/sql.js/dist/sql-wasm.wasm` to the `src/assets` folder of YOUR_APP
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
114
120
 
115
121
  #### For Vue & React frameworks
116
122
 
117
- - copy manually the file `sql-wasm.wasm` from `nodes_modules/sql.js/dist/sql-wasm.wasm` to the `public/assets` folder of YOUR_APP
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
118
124
 
119
125
  ### IOS
120
126
 
@@ -319,17 +325,18 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
319
325
  <table>
320
326
  <tr>
321
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>
322
- <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=jepiqueau" title="Code">💻</a></td>
323
- <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=jepiqueau" title="Code">💻</a></td>
324
- <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=jepiqueau" title="Documentation">📖</a></td>
325
- <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=jepiqueau" title="Code">💻</a></td>
326
- <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=jepiqueau" title="Code">💻</a></td>
327
- <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=jepiqueau" title="Code">💻</a></td>
328
- <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=jepiqueau" title="Code">💻</a></td>
329
- <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=jepiqueau" title="Documentation">📖</a></td>
330
- <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=jepiqueau" title="Documentation">📖</a></td>
331
- <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=jepiqueau" title="Code">💻</a></td>
332
- </tr>
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>
333
340
  </table>
334
341
 
335
342
  <!-- markdownlint-enable -->
@@ -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 = "isDBExists: " + e.getMessage();
943
+ String msg = "IsJsonValid: " + e.getMessage();
944
944
  rHandler.retResult(call, false, msg);
945
945
  return;
946
946
  }
@@ -129,7 +129,8 @@ public class Database {
129
129
  * @return database url
130
130
  */
131
131
  public String getUrl() {
132
- return this._file.getAbsolutePath();
132
+ String url = "file://";
133
+ return url + this._file.getAbsolutePath();
133
134
  }
134
135
 
135
136
  /**
@@ -370,7 +371,8 @@ public class Database {
370
371
  }
371
372
  if (lastId == -1) break;
372
373
  }
373
- if (lastId != -1) {
374
+ changes = _uSqlite.dbChanges(_db) - initChanges;
375
+ if (changes >= 0) {
374
376
  if (transaction) _db.setTransactionSuccessful();
375
377
  changes = _uSqlite.dbChanges(_db) - initChanges;
376
378
  retObj.put("changes", changes);
@@ -456,10 +458,11 @@ public class Database {
456
458
  SimpleSQLiteQuery.bind(stmt, valObj);
457
459
  }
458
460
  if (stmtType.equals("INSERT")) {
459
- return stmt.executeInsert();
461
+ stmt.executeInsert();
460
462
  } else {
461
- return Long.valueOf(stmt.executeUpdateDelete());
463
+ stmt.executeUpdateDelete();
462
464
  }
465
+ return _uSqlite.dbLastId(_db);
463
466
  } catch (IllegalStateException e) {
464
467
  throw new Exception(e.getMessage());
465
468
  } catch (IllegalArgumentException e) {
@@ -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