From 1462f5950fd47ecf395cff3fbf5fe0107beec3bb Mon Sep 17 00:00:00 2001
From: QUEAU Jean Pierre
Date: Fri, 10 Mar 2023 21:05:31 +0100
Subject: [PATCH] fix issue#386 Android comment in SQL
---
CHANGELOG.md | 8 ++++++++
README.md | 3 ++-
.../buildOutputCleanup/buildOutputCleanup.lock | Bin 17 -> 17 bytes
.../database/sqlite/SQLite/UtilsSQLite.java | 10 ++++++----
docs/API.md | 4 ++++
5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 806ac0ac..79abdb03 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# 4.6.3-3 (2023-03-10)
+
+### Bug Fixes
+
+- Fix Strip comment lines when using CapacitorSQLite.execute (Android} PR#387 by patdx
+- Fix CapacitorSQLite.execute on Android does not support comments issue#386
+- Add Comments within SQL statements in API.md
+
# 4.6.3-2 (2023-03-10)
### Bug Fixes
diff --git a/README.md b/README.md
index 29ebbf01..5ac630c2 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
-
+
@@ -345,6 +345,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
+
diff --git a/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index b028d1590fdb660cfa8b020b348001b50181f861..ad0844b6aa8d30a51fdaf6bd6a4efb3f19c43376 100644
GIT binary patch
literal 17
VcmZRcClSiQIY+IV0SvxG0{|dg1H1qL
literal 17
VcmZRcClSiQIY+IV0SrFg0RSM^1Udi!
diff --git a/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java b/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java
index 69b8d8b0..6d9cd10e 100644
--- a/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java
+++ b/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java
@@ -64,13 +64,15 @@ public String[] getStatementsArray(String statements) {
StringBuilder builder = new StringBuilder();
for (String s : array) {
String line = s.trim();
- if (line.startsWith("--")) {
- // is a comment, do nothing
- } else if (s.length() > 0) {
+ int idx = line.indexOf("--");
+ if(idx > -1) {
+ line = line.substring(0, idx);
+ }
+ if(line.length() > 0) {
if (builder.length() > 0) {
builder.append(" ");
}
- builder.append(s);
+ builder.append(line);
}
}
diff --git a/docs/API.md b/docs/API.md
index 319f8575..d5d74339 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -91,6 +91,10 @@ The plugin add a suffix "SQLite" and an extension ".db" to the database name giv
- the database is stored in Web browser INDEXEDDB storage as a `localforage` store under the `jeepSqliteStore` name and `databases` table name.
+## Comments within SQL statements
+
+ - see [Comments within SQL](https://www.techonthenet.com/sqlite/comments.php)
+
## Write-Ahead Logging (WAL)
- Electron, Web platforms only WAL journal_mode is implemented