@capacitor-community/sqlite 5.0.0-beta.0 → 5.0.0-beta.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
@@ -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-32-orange?style=flat-square" /></a>
19
+ <a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-33-orange?style=flat-square" /></a>
20
20
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
21
21
  </p>
22
22
 
@@ -251,6 +251,7 @@ npm install --save-dev @types/sqlite3
251
251
 
252
252
  - [Biometric Authentication](https://github.com/capacitor-community/sqlite/blob/master/docs/Biometric-Authentication.md)
253
253
 
254
+ - [Enable SQLite Schema Error Syntax Highlighting](https://github.com/capacitor-community/sqlite/blob/master/docs/SyntaxScanner-For-SQLite-Code.md)
254
255
 
255
256
  ## Applications demonstrating the use of the plugin and related documentation
256
257
 
@@ -349,6 +350,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
349
350
  <a href="https://github.com/eppineda" title="eppineda"><img src="https://github.com/eppineda.png?size=100" width="50" height="50" /></a>
350
351
  <a href="https://github.com/patdx" title="patdx"><img src="https://github.com/patdx.png?size=100" width="50" height="50" /></a>
351
352
  <a href="https://github.com/folsze" title="folsze"><img src="https://github.com/folsze.png?size=100" width="50" height="50" /></a>
353
+ <a href="https://github.com/pranav-singhal" title="pranav-singhal"><img src="https://github.com/pranav-singhal.png?size=100" width="50" height="50" /></a>
352
354
  </p>
353
355
 
354
356
 
@@ -11,7 +11,7 @@ buildscript {
11
11
  mavenCentral()
12
12
  }
13
13
  dependencies {
14
- classpath 'com.android.tools.build:gradle:7.4.1'
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
15
  }
16
16
  }
17
17
 
@@ -40,8 +40,8 @@ android {
40
40
  abortOnError false
41
41
  }
42
42
  compileOptions {
43
- sourceCompatibility JavaVersion.VERSION_11
44
- targetCompatibility JavaVersion.VERSION_11
43
+ sourceCompatibility JavaVersion.VERSION_17
44
+ targetCompatibility JavaVersion.VERSION_17
45
45
  }
46
46
  }
47
47
 
@@ -70,7 +70,7 @@ dependencies {
70
70
  implementation 'net.zetetic:android-database-sqlcipher:4.5.3'
71
71
  implementation "androidx.sqlite:sqlite:2.3.1"
72
72
  //security library
73
- implementation "androidx.security:security-crypto:1.1.0-alpha05"
73
+ implementation "androidx.security:security-crypto:1.1.0-alpha06"
74
74
  implementation "androidx.biometric:biometric:1.1.0"
75
75
  annotationProcessor 'androidx.room:room-compiler:2.5.1'
76
76
  }
@@ -383,14 +383,12 @@ public class ImportFromJson {
383
383
  ArrayList<String> tColNames = new ArrayList<>();
384
384
  ArrayList<String> tColTypes = new ArrayList<>();
385
385
  if (tableNamesTypes.has("names")) {
386
- tColNames = _uJson.
387
- JSONArrayToArrayList(tableNamesTypes.getJSONArray("names"));
386
+ tColNames = _uJson.getColumnNames(tableNamesTypes.get("names"));
388
387
  } else {
389
388
  throw new Exception("GetValues: Table " + tableName + " no names");
390
389
  }
391
390
  if (tableNamesTypes.has("types")) {
392
- tColTypes = _uJson.
393
- JSONArrayToArrayList(tableNamesTypes.getJSONArray("types"));
391
+ tColTypes = _uJson.getColumnNames(tableNamesTypes.get("types"));
394
392
  } else {
395
393
  throw new Exception("GetValues: Table " + tableName + " no types");
396
394
  }
@@ -559,14 +557,17 @@ public class ImportFromJson {
559
557
  if (row.get(idxDelete).equals(1)) {
560
558
  // Delete
561
559
  isUpdate = false;
562
- stmt =
560
+ Object key = tColNames.get(0);
561
+ StringBuilder sbQuery =
563
562
  new StringBuilder("DELETE FROM ")
564
563
  .append(tableName)
565
564
  .append(" WHERE ")
566
565
  .append(tColNames.get(0))
567
- .append(" = ")
568
- .append(row.get(0))
569
- .toString();
566
+ .append(" = ");
567
+
568
+ if (key instanceof Integer) sbQuery.append(row.get(0)).append(";");
569
+ if (key instanceof String) sbQuery.append("'").append(row.get(0)).append("';");
570
+ stmt = sbQuery.toString();
570
571
  }
571
572
  }
572
573
  if (isUpdate) {
@@ -6,6 +6,7 @@ import com.getcapacitor.community.database.sqlite.SQLite.Database;
6
6
  import com.getcapacitor.community.database.sqlite.SQLite.UtilsDrop;
7
7
  import java.sql.Blob;
8
8
  import java.util.ArrayList;
9
+ import java.util.Arrays;
9
10
  import java.util.Iterator;
10
11
  import java.util.List;
11
12
 
@@ -38,13 +39,12 @@ public class UtilsJson {
38
39
  JSObject namesTypes = getTableColumnNamesTypes(db, tableName);
39
40
  ArrayList<String> colNames = new ArrayList<>();
40
41
  if (namesTypes.has("names")) {
41
- colNames =
42
- JSONArrayToArrayList(namesTypes.getJSONArray("names"));
42
+ colNames = getColumnNames(namesTypes.get("names"));
43
43
  } else {
44
- throw new Exception("isLastModified: Table " + tableName + " no names");
44
+ throw new Exception("isLastModified: Table " + tableName + " no names");
45
45
  }
46
46
 
47
- if (colNames.contains("last_modified")) {
47
+ if (colNames.size() > 0 && colNames.contains("last_modified")) {
48
48
  ret = true;
49
49
  break;
50
50
  }
@@ -55,6 +55,18 @@ public class UtilsJson {
55
55
  }
56
56
  }
57
57
 
58
+ /**
59
+ * Get Column name's list
60
+ * @param obj
61
+ * @return
62
+ */
63
+ public ArrayList<String> getColumnNames(Object obj) {
64
+
65
+ ArrayList<String> colNames = new ArrayList<>();
66
+ if (obj instanceof ArrayList) colNames = (ArrayList<String>) obj;
67
+
68
+ return colNames;
69
+ }
58
70
  /**
59
71
  * Check existence of sql_deleted column
60
72
  * @param db
@@ -72,8 +84,7 @@ public class UtilsJson {
72
84
  JSObject namesTypes = getTableColumnNamesTypes(db, tableName);
73
85
  ArrayList<String> colNames = new ArrayList<>();
74
86
  if (namesTypes.has("names")) {
75
- colNames =
76
- JSONArrayToArrayList(namesTypes.getJSONArray("names"));
87
+ colNames = getColumnNames(namesTypes.get("names"));
77
88
  } else {
78
89
  throw new Exception("isSqlDeleted: Table " + tableName + " no names");
79
90
  }
@@ -487,13 +498,12 @@ public class UtilsJson {
487
498
  ArrayList<String> rowTypes = new ArrayList<>();
488
499
  ArrayList<String> rowNames = new ArrayList<>();
489
500
  if (tableNamesTypes.has("names")) {
490
- rowNames =
491
- JSONArrayToArrayList(tableNamesTypes.getJSONArray("names"));
501
+ rowNames = getColumnNames(tableNamesTypes.get("names"));
492
502
  } else {
493
503
  throw new Exception("GetValues: Table " + tableName + " no names");
494
504
  }
495
505
  if (tableNamesTypes.has("types")) {
496
- rowTypes = JSONArrayToArrayList(tableNamesTypes.getJSONArray("types"));
506
+ rowTypes = getColumnNames(tableNamesTypes.get("types"));
497
507
  } else {
498
508
  throw new Exception("GetValues: Table " + tableName + " no types");
499
509
  }
@@ -545,11 +555,4 @@ public class UtilsJson {
545
555
  }
546
556
  return row;
547
557
  }
548
- public ArrayList<String> JSONArrayToArrayList(JSONArray arr) throws JSONException {
549
- ArrayList<String> retArr = new ArrayList<>();
550
- for (int i=0; i<arr.length(); i++) {
551
- retArr.add(arr.getString(i));
552
- }
553
- return retArr;
554
- }
555
558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.2",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -56,11 +56,11 @@
56
56
  "prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
57
57
  },
58
58
  "devDependencies": {
59
- "@capacitor/android": "^5.0.0-beta.1",
60
- "@capacitor/cli": "^5.0.0-beta.1",
61
- "@capacitor/core": "^5.0.0-beta.1",
59
+ "@capacitor/android": "^5.0.0",
60
+ "@capacitor/cli": "^5.0.0",
61
+ "@capacitor/core": "^5.0.0",
62
62
  "@capacitor/docgen": "^0.0.17",
63
- "@capacitor/ios": "^5.0.0-beta.1",
63
+ "@capacitor/ios": "^5.0.0",
64
64
  "@ionic/eslint-config": "^0.3.0",
65
65
  "@ionic/prettier-config": "^1.0.1",
66
66
  "@ionic/swiftlint-config": "^1.1.2",
@@ -95,6 +95,6 @@
95
95
  }
96
96
  },
97
97
  "dependencies": {
98
- "jeep-sqlite": "^2.3.1"
98
+ "jeep-sqlite": "^2.3.3"
99
99
  }
100
100
  }