Skip to content

Commit 5936b53

Browse files
committed
fix deleteSQL: Did not find column names issue#470
1 parent e041195 commit 5936b53

34 files changed

+1881
-1611
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 5.2.4 (2023-09-27)
2+
3+
### Bug Fixes
4+
5+
- Fix Bug: deleteSQL: Did not find column names in the WHERE Statement issue#470 all platforms
6+
17
# 5.2.3 (2023-09-03)
28

39
### Chore
0 Bytes
Binary file not shown.
108 Bytes
Binary file not shown.

android/.idea/misc.xml

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

android/.idea/workspace.xml

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

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
55
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
8-
java.home=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
8+
java.home=/usr
99
jvm.arguments=
1010
offline.mode=false
1111
override.workspace.settings=true

android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ public void close(String dbName, Boolean readonly) throws Exception {
451451
throw new Exception(msg);
452452
}
453453
}
454+
454455
/**
455456
* BeginTransaction
456457
*
@@ -466,7 +467,7 @@ public JSObject beginTransaction(String dbName) throws Exception {
466467
if (db != null) {
467468
if (!db.isNCDB() && db.isOpen()) {
468469
try {
469-
Integer res = db.beginTransaction();
470+
Integer res = db.beginTransaction();
470471
retObj.put("changes", res);
471472
return retObj;
472473
} catch (Exception e) {
@@ -497,7 +498,7 @@ public JSObject commitTransaction(String dbName) throws Exception {
497498
if (db != null) {
498499
if (!db.isNCDB() && db.isOpen()) {
499500
try {
500-
Integer res = db.commitTransaction();
501+
Integer res = db.commitTransaction();
501502
retObj.put("changes", res);
502503
return retObj;
503504
} catch (Exception e) {
@@ -528,7 +529,7 @@ public JSObject rollbackTransaction(String dbName) throws Exception {
528529
if (db != null) {
529530
if (!db.isNCDB() && db.isOpen()) {
530531
try {
531-
Integer res = db.rollbackTransaction();
532+
Integer res = db.rollbackTransaction();
532533
retObj.put("changes", res);
533534
return retObj;
534535
} catch (Exception e) {
@@ -563,7 +564,6 @@ public Boolean isTransactionActive(String dbName) throws Exception {
563564
} catch (Exception e) {
564565
throw new Exception(e.getMessage());
565566
}
566-
567567
} else {
568568
String msg = "database " + dbName + " not opened";
569569
throw new Exception(msg);
@@ -1269,8 +1269,7 @@ public JSObject importFromJson(String parsingData) throws Exception {
12691269
}
12701270
}
12711271

1272-
public JSObject exportToJson(String dbName, String expMode,
1273-
Boolean readonly, Boolean encrypted) throws Exception {
1272+
public JSObject exportToJson(String dbName, String expMode, Boolean readonly, Boolean encrypted) throws Exception {
12741273
dbName = getDatabaseName(dbName);
12751274
String connName = readonly ? "RO_" + dbName : "RW_" + dbName;
12761275
Database db = dbDict.get(connName);

android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.getcapacitor.PluginMethod;
1010
import com.getcapacitor.annotation.CapacitorPlugin;
1111
import com.getcapacitor.community.database.sqlite.SQLite.SqliteConfig;
12+
import java.util.ArrayList;
13+
import java.util.Arrays;
1214
import java.util.Collections;
1315
import java.util.Dictionary;
1416
import java.util.Hashtable;
@@ -28,6 +30,9 @@ public class CapacitorSQLitePlugin extends Plugin {
2830
private String passphrase = null;
2931
private String oldpassphrase = null;
3032
private String loadMessage = "";
33+
private final ArrayList<String> modeList = new ArrayList<>(
34+
Arrays.asList("no-encryption", "encryption", "secret", "decryption", "wrongsecret")
35+
);
3136

3237
/**
3338
* Load Method
@@ -287,12 +292,9 @@ public void createConnection(PluginCall call) {
287292
Boolean encrypted = call.getBoolean("encrypted", false);
288293
if (encrypted) {
289294
inMode = call.getString("mode", "no-encryption");
290-
if (
291-
!inMode.equals("no-encryption") && !inMode.equals("encryption") && !inMode.equals("secret") && !inMode.equals("wrongsecret")
292-
) {
295+
if (!modeList.contains(inMode)) {
293296
String msg = "CreateConnection: inMode must ";
294-
msg += "be in ['encryption','secret'] ";
295-
msg += "** 'newsecret' has been deprecated";
297+
msg += "be in ['encryption','secret', 'decryption'] ";
296298
rHandler.retResult(call, null, msg);
297299
return;
298300
}
@@ -369,6 +371,7 @@ public void close(PluginCall call) {
369371
rHandler.retResult(call, null, loadMessage);
370372
}
371373
}
374+
372375
/**
373376
* BeginTransaction Method
374377
* Begin a Database Transaction
@@ -398,6 +401,7 @@ public void beginTransaction(PluginCall call) {
398401
rHandler.retChanges(call, retRes, loadMessage);
399402
}
400403
}
404+
401405
/**
402406
* CommitTransaction Method
403407
* Commit a Database Transaction
@@ -457,6 +461,7 @@ public void rollbackTransaction(PluginCall call) {
457461
rHandler.retChanges(call, retRes, loadMessage);
458462
}
459463
}
464+
460465
/**
461466
* IsTransactionActive Method
462467
* Check if a Database Transaction is Active
@@ -482,6 +487,7 @@ public void isTransactionActive(PluginCall call) {
482487
rHandler.retResult(call, null, loadMessage);
483488
}
484489
}
490+
485491
/**
486492
* GetUrl Method
487493
* Get a database Url
@@ -1452,8 +1458,7 @@ public void exportToJson(PluginCall call) {
14521458

14531459
if (implementation != null) {
14541460
try {
1455-
JSObject res = implementation.exportToJson(dbName, expMode,
1456-
readOnly, encrypted);
1461+
JSObject res = implementation.exportToJson(dbName, expMode, readOnly, encrypted);
14571462
rHandler.retJSObject(call, res, null);
14581463
} catch (Exception e) {
14591464
String msg = "ExportToJson: " + e.getMessage();

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public Boolean isNCDB() {
144144
public boolean isAvailTrans() {
145145
return _db.inTransaction();
146146
}
147+
147148
/**
148149
* BeginTransaction method
149150
*
@@ -152,7 +153,7 @@ public boolean isAvailTrans() {
152153
public Integer beginTransaction() throws Exception {
153154
if (_db.isOpen()) {
154155
try {
155-
if( isAvailTrans()) {
156+
if (isAvailTrans()) {
156157
throw new Exception("Already in transaction");
157158
}
158159
_db.beginTransaction();
@@ -165,8 +166,8 @@ public Integer beginTransaction() throws Exception {
165166
} else {
166167
throw new Exception("Database not opened");
167168
}
168-
169169
}
170+
170171
/**
171172
* CommitTransaction method
172173
*
@@ -175,7 +176,7 @@ public Integer beginTransaction() throws Exception {
175176
public Integer commitTransaction() throws Exception {
176177
if (_db.isOpen()) {
177178
try {
178-
if(!isAvailTrans()) {
179+
if (!isAvailTrans()) {
179180
throw new Exception("No transaction active");
180181
}
181182
_db.setTransactionSuccessful();
@@ -188,7 +189,6 @@ public Integer commitTransaction() throws Exception {
188189
} else {
189190
throw new Exception("Database not opened");
190191
}
191-
192192
}
193193

194194
/**
@@ -199,7 +199,7 @@ public Integer commitTransaction() throws Exception {
199199
public Integer rollbackTransaction() throws Exception {
200200
if (_db.isOpen()) {
201201
try {
202-
if( isAvailTrans()) {
202+
if (isAvailTrans()) {
203203
_db.endTransaction();
204204
}
205205
return 0;
@@ -211,7 +211,6 @@ public Integer rollbackTransaction() throws Exception {
211211
} else {
212212
throw new Exception("Database not opened");
213213
}
214-
215214
}
216215

217216
/**
@@ -233,7 +232,7 @@ public void open() throws Exception {
233232
int curVersion;
234233

235234
String password = "";
236-
if (_encrypted && (_mode.equals("secret") || _mode.equals("encryption"))) {
235+
if (_encrypted && (_mode.equals("secret") || _mode.equals("encryption") || _mode.equals("decryption"))) {
237236
if (!_uSecret.isPassphrase()) {
238237
throw new Exception("No Passphrase stored");
239238
}
@@ -252,6 +251,20 @@ public void open() throws Exception {
252251
throw new Exception("No Encryption set in capacitor.config");
253252
}
254253
}
254+
if (_mode.equals("decryption")) {
255+
if (_isEncryption) {
256+
try {
257+
_uCipher.decrypt(_context, _file, SQLiteDatabase.getBytes(password.toCharArray()));
258+
password = "";
259+
} catch (Exception e) {
260+
String msg = "Failed in decryption " + e.getMessage();
261+
Log.v(TAG, msg);
262+
throw new Exception(msg);
263+
}
264+
} else {
265+
throw new Exception("No Encryption set in capacitor.config");
266+
}
267+
}
255268
try {
256269
if (!isNCDB() && !this._readOnly) {
257270
_db = SQLiteDatabase.openOrCreateDatabase(_file, password, null);

0 commit comments

Comments
 (0)