@capacitor-community/sqlite 5.6.1 → 5.6.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 +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +22 -6
- package/electron/dist/plugin.js +25 -33
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +18 -12
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +31 -9
- package/package.json +2 -2
package/README.md
CHANGED
package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java
CHANGED
|
@@ -743,24 +743,40 @@ public class Database {
|
|
|
743
743
|
if (returningIndex != -1) {
|
|
744
744
|
String substring = suffix.substring(returningIndex + "returning".length());
|
|
745
745
|
String names = substring.trim();
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
}
|
|
746
|
+
retObj.put("names", getNames(names));
|
|
747
|
+
}
|
|
750
748
|
}
|
|
751
749
|
return retObj;
|
|
752
750
|
}
|
|
753
751
|
|
|
752
|
+
private String getNames(String input) {
|
|
753
|
+
int indexSemicolon = input.indexOf(";");
|
|
754
|
+
int indexDoubleDash = input.indexOf("--");
|
|
755
|
+
int indexCommentStart = input.indexOf("/*");
|
|
756
|
+
|
|
757
|
+
// Find the minimum index among them
|
|
758
|
+
int minIndex = input.length();
|
|
759
|
+
if (indexSemicolon != -1) {
|
|
760
|
+
minIndex = Math.min(minIndex, indexSemicolon);
|
|
761
|
+
}
|
|
762
|
+
if (indexDoubleDash != -1) {
|
|
763
|
+
minIndex = Math.min(minIndex, indexDoubleDash);
|
|
764
|
+
}
|
|
765
|
+
if (indexCommentStart != -1) {
|
|
766
|
+
minIndex = Math.min(minIndex, indexCommentStart);
|
|
767
|
+
}
|
|
768
|
+
return input.substring(0, minIndex).trim();
|
|
769
|
+
}
|
|
754
770
|
private JSObject isReturning(String sqlStmt) {
|
|
755
771
|
JSObject retObj = new JSObject();
|
|
756
772
|
|
|
757
|
-
String stmt = sqlStmt.
|
|
773
|
+
String stmt = sqlStmt.trim();
|
|
758
774
|
if (stmt.endsWith(";")) {
|
|
759
775
|
// Remove the suffix
|
|
760
776
|
stmt = stmt.substring(0, stmt.length() - 1).trim();
|
|
761
777
|
}
|
|
762
778
|
retObj.put("isReturning", false);
|
|
763
|
-
retObj.put("stmt",
|
|
779
|
+
retObj.put("stmt", sqlStmt);
|
|
764
780
|
retObj.put("names", "");
|
|
765
781
|
|
|
766
782
|
switch (stmt.substring(0, Math.min(stmt.length(), 6)).toUpperCase()) {
|
package/electron/dist/plugin.js
CHANGED
|
@@ -1098,29 +1098,6 @@ class UtilsSQLStatement {
|
|
|
1098
1098
|
const lines = input.split(/\r?\n/);
|
|
1099
1099
|
return lines.join(' ');
|
|
1100
1100
|
}
|
|
1101
|
-
getStmtAndRetColNames(sqlStmt, retMode) {
|
|
1102
|
-
const retWord = 'RETURNING';
|
|
1103
|
-
const retStmtNames = {
|
|
1104
|
-
stmt: sqlStmt,
|
|
1105
|
-
names: '',
|
|
1106
|
-
};
|
|
1107
|
-
const retWordIndex = sqlStmt.toUpperCase().indexOf(retWord);
|
|
1108
|
-
if (retWordIndex !== -1) {
|
|
1109
|
-
const prefix = sqlStmt.substring(0, retWordIndex);
|
|
1110
|
-
retStmtNames.stmt = `${prefix};`;
|
|
1111
|
-
if (retMode.substring(0, 2) === 'wA') {
|
|
1112
|
-
const suffix = sqlStmt.substring(retWordIndex + retWord.length);
|
|
1113
|
-
const names = suffix.trim();
|
|
1114
|
-
if (names.endsWith(';')) {
|
|
1115
|
-
retStmtNames.names = names.substring(0, names.length - 1);
|
|
1116
|
-
}
|
|
1117
|
-
else {
|
|
1118
|
-
retStmtNames.names = names;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
return retStmtNames;
|
|
1123
|
-
}
|
|
1124
1101
|
extractCombinedPrimaryKey(whereClause) {
|
|
1125
1102
|
const pattern = /WHERE\s*\((.+?)\)\s*(?:=|IN)\s*\((.+?)\)/g;
|
|
1126
1103
|
const regex = new RegExp(pattern);
|
|
@@ -1540,7 +1517,7 @@ class UtilsSQLite {
|
|
|
1540
1517
|
}
|
|
1541
1518
|
statementsToSQL92(mDB, sql, fromJson, isSQL92) {
|
|
1542
1519
|
// split the statements in an array of statement
|
|
1543
|
-
let sqlStmt = sql
|
|
1520
|
+
let sqlStmt = sql /*.replace(/\n/g, '')*/;
|
|
1544
1521
|
// deal with trigger
|
|
1545
1522
|
sqlStmt = sqlStmt.replace(/end;/g, 'END;');
|
|
1546
1523
|
sqlStmt = sqlStmt.replace(/;END;/g, '&END;');
|
|
@@ -1589,7 +1566,7 @@ class UtilsSQLite {
|
|
|
1589
1566
|
}
|
|
1590
1567
|
resArr.push(rStmt);
|
|
1591
1568
|
}
|
|
1592
|
-
sqlStmt = resArr.join('
|
|
1569
|
+
sqlStmt = resArr.join(';\n');
|
|
1593
1570
|
return sqlStmt;
|
|
1594
1571
|
}
|
|
1595
1572
|
/**
|
|
@@ -1678,7 +1655,7 @@ class UtilsSQLite {
|
|
|
1678
1655
|
const result = { changes: 0, lastId: -1 };
|
|
1679
1656
|
const msg = 'PrepareRun';
|
|
1680
1657
|
const stmtType = statement
|
|
1681
|
-
.replace(/\n/g, '')
|
|
1658
|
+
// .replace(/\n/g, '')
|
|
1682
1659
|
.trim()
|
|
1683
1660
|
.substring(0, 6)
|
|
1684
1661
|
.toUpperCase();
|
|
@@ -2327,7 +2304,7 @@ class UtilsSQLite {
|
|
|
2327
2304
|
return retStmt;
|
|
2328
2305
|
}
|
|
2329
2306
|
isReturning(sqlStmt) {
|
|
2330
|
-
let stmt = sqlStmt.
|
|
2307
|
+
let stmt = sqlStmt.trim();
|
|
2331
2308
|
if (stmt.endsWith(';')) {
|
|
2332
2309
|
stmt = stmt.slice(0, -1).trim();
|
|
2333
2310
|
}
|
|
@@ -2410,16 +2387,31 @@ class UtilsSQLite {
|
|
|
2410
2387
|
if (returningIndex !== -1) {
|
|
2411
2388
|
const substring = suffix.slice(returningIndex + 9); // 9 is the length of "returning"
|
|
2412
2389
|
const names = substring.trim();
|
|
2413
|
-
|
|
2414
|
-
retObj.names = names.slice(0, -1);
|
|
2415
|
-
}
|
|
2416
|
-
else {
|
|
2417
|
-
retObj.names = names;
|
|
2418
|
-
}
|
|
2390
|
+
retObj.names = this.getNames(names);
|
|
2419
2391
|
}
|
|
2420
2392
|
}
|
|
2421
2393
|
return retObj;
|
|
2422
2394
|
}
|
|
2395
|
+
getNames(input) {
|
|
2396
|
+
// Find the index of the first occurrence of ";", "--", or "/*"
|
|
2397
|
+
const indexSemicolon = input.indexOf(';');
|
|
2398
|
+
const indexDoubleDash = input.indexOf('--');
|
|
2399
|
+
const indexCommentStart = input.indexOf('/*');
|
|
2400
|
+
// Find the minimum index among them
|
|
2401
|
+
let minIndex = input.length;
|
|
2402
|
+
if (indexSemicolon !== -1) {
|
|
2403
|
+
minIndex = Math.min(minIndex, indexSemicolon);
|
|
2404
|
+
}
|
|
2405
|
+
if (indexDoubleDash !== -1) {
|
|
2406
|
+
minIndex = Math.min(minIndex, indexDoubleDash);
|
|
2407
|
+
}
|
|
2408
|
+
if (indexCommentStart !== -1) {
|
|
2409
|
+
minIndex = Math.min(minIndex, indexCommentStart);
|
|
2410
|
+
}
|
|
2411
|
+
// Extract substring up to the minimum index
|
|
2412
|
+
const colnames = input.substring(0, minIndex).trim();
|
|
2413
|
+
return colnames;
|
|
2414
|
+
}
|
|
2423
2415
|
getTableName(sqlStatement) {
|
|
2424
2416
|
const patterns = {
|
|
2425
2417
|
insert: /INSERT\s+INTO\s+(\w+)/i,
|