Skip to content

Commit 8bdcc5e

Browse files
committed
fix issue#492 Android
1 parent a0cf6da commit 8bdcc5e

File tree

5 files changed

+44
-24
lines changed

5 files changed

+44
-24
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# 5.5.1-1 (2023-12-15)
2+
3+
### Chore
4+
5+
- Update to @capacitor/core@5.5.1
6+
- Update to @capacitor/ios@5.5.1
7+
- Update to @capacitor/android@5.5.1
8+
9+
### Bug Fixes
10+
11+
- Fix importFromJson on android fails to build SQL Statement with ' in values. issue#492
12+
113
# 5.5.0 (2023-12-13)
214

315
### Chore
0 Bytes
Binary file not shown.

android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,12 @@ private JSONObject generateInsertAndDeletedStrings(ArrayList<String> tColNames,
458458
String formattedRow = null;
459459
formattedRow = String.join(", ", rowIndex.stream().map(item -> {
460460
if (item instanceof String) {
461-
StringBuilder formattedValue = new StringBuilder();
462-
formattedValue.append('"').append(item).append('"');
463-
return formattedValue.toString();
461+
String val = (String) item;
462+
String rVal = val;
463+
if(val.contains("'")) {
464+
rVal = val.replace("'","''");
465+
}
466+
return "'" + rVal + "'";
464467
} else {
465468
return item.toString();
466469
}
@@ -474,7 +477,12 @@ private JSONObject generateInsertAndDeletedStrings(ArrayList<String> tColNames,
474477
}
475478
Object item = rowIndex.get(i);
476479
if (item instanceof String) {
477-
formattedRow.append('"').append(item).append('"');
480+
String val = (String) item;
481+
String rVal = val;
482+
if(val.contains("'")) {
483+
rVal = val.replace("'","''");
484+
}
485+
formattedRow.append("'").append(rVal).append("'");
478486
} else {
479487
formattedRow.append(item);
480488
}

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
6060
},
6161
"devDependencies": {
62-
"@capacitor/android": "^5.5.0",
63-
"@capacitor/cli": "^5.5.0",
64-
"@capacitor/core": "^5.5.0",
62+
"@capacitor/android": "^5.5.1",
63+
"@capacitor/cli": "^5.5.1",
64+
"@capacitor/core": "^5.5.1",
6565
"@capacitor/docgen": "^0.0.17",
66-
"@capacitor/ios": "^5.5.0",
66+
"@capacitor/ios": "^5.5.1",
6767
"@ionic/eslint-config": "^0.3.0",
6868
"@ionic/prettier-config": "^1.0.1",
6969
"@ionic/swiftlint-config": "^1.1.2",

0 commit comments

Comments
 (0)