@capacitor-community/sqlite 6.0.1 → 6.0.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 +71 -91
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +12 -16
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +2 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +73 -69
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDownloadFromHTTP.java +13 -12
- package/dist/esm/definitions.js +1 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -4
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +56 -144
- package/electron/dist/plugin.js.map +1 -1
- package/electron/rollup.config.js +1 -3
- package/ios/Plugin/CapacitorSQLite.swift +5 -5
- package/ios/Plugin/Database.swift +1 -1
- package/ios/Plugin/ImportExportJson/ExportToJson.swift +7 -7
- package/ios/Plugin/Models/KeychainServices.swift +1 -1
- package/ios/Plugin/Utils/UtilsBinding.swift +2 -2
- package/ios/Plugin/Utils/UtilsDelete.swift +4 -4
- package/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +2 -2
- package/ios/Plugin/Utils/UtilsDrop.swift +1 -1
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +17 -17
- package/ios/Plugin/Utils/UtilsSQLStatement.swift +120 -121
- package/package.json +23 -21
- package/src/definitions.ts +44 -128
- package/src/index.ts +4 -8
- package/src/web.ts +60 -132
|
@@ -29,9 +29,7 @@ export default {
|
|
|
29
29
|
nodeResolve(),
|
|
30
30
|
commonjs({
|
|
31
31
|
ignoreDynamicRequires: true,
|
|
32
|
-
dynamicRequireTargets: [
|
|
33
|
-
'node_modules/@capacitor-community/sqlite/electron/dist/plugin.js',
|
|
34
|
-
],
|
|
32
|
+
dynamicRequireTargets: ['node_modules/@capacitor-community/sqlite/electron/dist/plugin.js'],
|
|
35
33
|
}),
|
|
36
34
|
],
|
|
37
35
|
};
|
|
@@ -247,7 +247,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
247
247
|
|
|
248
248
|
// MARK: - CheckEncryptionSecret
|
|
249
249
|
|
|
250
|
-
@objc public func checkEncryptionSecret(passphrase: String) throws ->
|
|
250
|
+
@objc public func checkEncryptionSecret(passphrase: String) throws -> NSNumber {
|
|
251
251
|
guard isInit else {
|
|
252
252
|
throw CapacitorSQLiteError.failed(message: initMessage)
|
|
253
253
|
}
|
|
@@ -557,7 +557,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
557
557
|
// MARK: - GetVersion
|
|
558
558
|
|
|
559
559
|
@objc public func getVersion(_ dbName: String, readonly: Bool)
|
|
560
|
-
throws ->
|
|
560
|
+
throws -> NSNumber {
|
|
561
561
|
guard isInit else {
|
|
562
562
|
throw CapacitorSQLiteError.failed(message: initMessage)
|
|
563
563
|
}
|
|
@@ -585,7 +585,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
585
585
|
UtilsDownloadFromHTTP.download(databaseLocation: databaseLocation,
|
|
586
586
|
url: url) { ( result) in
|
|
587
587
|
switch result {
|
|
588
|
-
case .success
|
|
588
|
+
case .success:
|
|
589
589
|
self.retHandler.rResult(call: call)
|
|
590
590
|
return
|
|
591
591
|
case .failure(let error):
|
|
@@ -624,7 +624,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
624
624
|
|
|
625
625
|
@objc public func checkConnectionsConsistency(_ dbNames: [String],
|
|
626
626
|
openModes: [String])
|
|
627
|
-
throws ->
|
|
627
|
+
throws -> NSNumber {
|
|
628
628
|
guard isInit else {
|
|
629
629
|
throw CapacitorSQLiteError.failed(message: initMessage)
|
|
630
630
|
}
|
|
@@ -1033,7 +1033,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
1033
1033
|
account: account)
|
|
1034
1034
|
if !isEncryption &&
|
|
1035
1035
|
(state.rawValue == "ENCRYPTEDGLOBALSECRET" ||
|
|
1036
|
-
|
|
1036
|
+
state.rawValue == "ENCRYPTEDSECRET") {
|
|
1037
1037
|
var msg = "Cannot delete an Encrypted database with "
|
|
1038
1038
|
msg += "No Encryption set in capacitor.config"
|
|
1039
1039
|
throw CapacitorSQLiteError.failed(message: msg)
|
|
@@ -214,7 +214,7 @@ class Database {
|
|
|
214
214
|
let msg: String = "Failed in deleteBackupDB \(message)"
|
|
215
215
|
throw DatabaseError.open(message: msg)
|
|
216
216
|
} catch UtilsUpgradeError.onUpgradeFailed(let message) {
|
|
217
|
-
//restore the database
|
|
217
|
+
// restore the database
|
|
218
218
|
do {
|
|
219
219
|
try UtilsSQLCipher
|
|
220
220
|
.restoreDB(databaseLocation: databaseLocation,
|
|
@@ -231,7 +231,7 @@ class ExportToJson {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
switch expMode {
|
|
234
|
-
case "partial"
|
|
234
|
+
case "partial":
|
|
235
235
|
tables = try ExportToJson
|
|
236
236
|
.getTablesPartial(mDB: mDB,
|
|
237
237
|
resTables: resTables)
|
|
@@ -1199,9 +1199,9 @@ class ExportToJson {
|
|
|
1199
1199
|
row.append(val)
|
|
1200
1200
|
} else if values[pos][names[jpos]] is Int64 && (
|
|
1201
1201
|
INTEGERAFFINITY.contains(types[jpos].uppercased()) ||
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1202
|
+
INTEGERAFFINITY.contains(types[jpos]
|
|
1203
|
+
.components(separatedBy: "(")[0].uppercased()) ||
|
|
1204
|
+
NUMERICAFFINITY.contains(types[jpos].uppercased())) {
|
|
1205
1205
|
guard let val = values[pos][names[jpos]] as? Int64
|
|
1206
1206
|
else {
|
|
1207
1207
|
throw ExportToJsonError.createValues(
|
|
@@ -1210,8 +1210,8 @@ class ExportToJson {
|
|
|
1210
1210
|
row.append(val)
|
|
1211
1211
|
} else if values[pos][names[jpos]] is Int64 && (
|
|
1212
1212
|
REALAFFINITY.contains(types[jpos].uppercased()) ||
|
|
1213
|
-
|
|
1214
|
-
|
|
1213
|
+
NUMERICAFFINITY.contains(types[jpos]
|
|
1214
|
+
.components(separatedBy: "(")[0].uppercased())) {
|
|
1215
1215
|
guard let val = values[pos][names[jpos]] as? Int64
|
|
1216
1216
|
else {
|
|
1217
1217
|
throw ExportToJsonError.createValues(
|
|
@@ -1221,7 +1221,7 @@ class ExportToJson {
|
|
|
1221
1221
|
} else if values[pos][names[jpos]] is Double && (
|
|
1222
1222
|
REALAFFINITY.contains(types[jpos].uppercased()) ||
|
|
1223
1223
|
NUMERICAFFINITY.contains(types[jpos]
|
|
1224
|
-
|
|
1224
|
+
.components(separatedBy: "(")[0].uppercased())) {
|
|
1225
1225
|
guard let val = values[pos][names[jpos]] as? Double
|
|
1226
1226
|
else {
|
|
1227
1227
|
throw ExportToJsonError.createValues(
|
|
@@ -74,7 +74,7 @@ class UtilsBinding {
|
|
|
74
74
|
let sortedValues = extractSortedValues(from: dict)
|
|
75
75
|
let data: Data = Data(sortedValues)
|
|
76
76
|
sqlite3_bind_blob(handle, Int32(idx), data.bytes,
|
|
77
|
-
|
|
77
|
+
Int32(data.bytes.count), SQLITETRANSIENT)
|
|
78
78
|
}
|
|
79
79
|
} else {
|
|
80
80
|
throw UtilsSQLCipherError.bindFailed
|
|
@@ -95,5 +95,5 @@ class UtilsBinding {
|
|
|
95
95
|
return false
|
|
96
96
|
}
|
|
97
97
|
return true
|
|
98
|
-
|
|
98
|
+
}
|
|
99
99
|
}
|
|
@@ -125,7 +125,7 @@ class UtilsDelete {
|
|
|
125
125
|
// update all related element
|
|
126
126
|
// set sql_deleted = 1 and last_modified
|
|
127
127
|
// tableName
|
|
128
|
-
//update all by sending return true
|
|
128
|
+
// update all by sending return true
|
|
129
129
|
results = try upDateWhereForCascade(
|
|
130
130
|
results: result)
|
|
131
131
|
|
|
@@ -342,7 +342,7 @@ class UtilsDelete {
|
|
|
342
342
|
colNames: [String], values: [Any])
|
|
343
343
|
throws {
|
|
344
344
|
var lastId: Int64 = -1
|
|
345
|
-
//update sql_deleted for this references
|
|
345
|
+
// update sql_deleted for this references
|
|
346
346
|
let stmt = "UPDATE \(tableName) SET \(setStmt) \(whereStmt)"
|
|
347
347
|
var selValues: [Any] = []
|
|
348
348
|
if !values.isEmpty {
|
|
@@ -450,8 +450,8 @@ class UtilsDelete {
|
|
|
450
450
|
throw UtilsDeleteError.getRefs(message: msg)
|
|
451
451
|
}
|
|
452
452
|
} else {
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
let msg = "getRefs: Error creating tableNameMatch "
|
|
454
|
+
throw UtilsDeleteError.getRefs(message: msg)
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
// Regular expression pattern to match the FOREIGN KEY
|
|
@@ -21,8 +21,8 @@ class UtilsDownloadFromHTTP {
|
|
|
21
21
|
class func download(databaseLocation: String, url: String,
|
|
22
22
|
completion: @escaping (Result<Bool, UtilsDownloadError>) -> Void) {
|
|
23
23
|
guard let fileDetails = getFileDetails(url: url),
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let fileExtension = fileDetails.extension,
|
|
25
|
+
fileExtension == "db" || fileExtension == "zip" else {
|
|
26
26
|
let msg = "download: Not a .zip or .db url"
|
|
27
27
|
print("\(msg)")
|
|
28
28
|
completion(.failure(UtilsDownloadError.downloadFromHTTPFailed(message: msg)))
|
|
@@ -192,7 +192,7 @@ class UtilsDrop {
|
|
|
192
192
|
.getTriggersNamesFailed(message: message)
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
//1234567890123456789012345678901234567890123456789012345678901234567890
|
|
195
|
+
// 1234567890123456789012345678901234567890123456789012345678901234567890
|
|
196
196
|
// MARK: - dropTriggers
|
|
197
197
|
|
|
198
198
|
class func dropTriggers(mDB: Database) throws -> Int {
|
|
@@ -456,9 +456,9 @@ class UtilsSQLCipher {
|
|
|
456
456
|
var result: [[String: Any]] = []
|
|
457
457
|
var retMode: String
|
|
458
458
|
let stmtType = sqlStmt
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
460
|
+
.components(separatedBy: " ")
|
|
461
|
+
.first?.capitalized ?? ""
|
|
462
462
|
|
|
463
463
|
if #available(iOS 15, *) {
|
|
464
464
|
retMode = returnMode
|
|
@@ -570,9 +570,9 @@ class UtilsSQLCipher {
|
|
|
570
570
|
var result: [[String: Any]] = []
|
|
571
571
|
let initLastId = Int64(sqlite3_last_insert_rowid(mDB.mDb))
|
|
572
572
|
let stmtType = sqlStmt
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
573
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
574
|
+
.components(separatedBy: " ")
|
|
575
|
+
.first?.capitalized ?? ""
|
|
576
576
|
|
|
577
577
|
if stmtType == "DELETE" &&
|
|
578
578
|
names.count > 0 {
|
|
@@ -986,17 +986,17 @@ class UtilsSQLCipher {
|
|
|
986
986
|
}
|
|
987
987
|
}
|
|
988
988
|
} else {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
989
|
+
let resp = try UtilsSQLCipher
|
|
990
|
+
.prepareSQL(mDB: mDB, sql: sql, values: values,
|
|
991
|
+
fromJson: false, returnMode: returnMode)
|
|
992
|
+
lastId = resp.0
|
|
993
|
+
respSet = resp.1
|
|
994
|
+
if lastId == -1 {
|
|
995
|
+
let message: String = "lastId < 0"
|
|
996
|
+
throw UtilsSQLCipherError.executeSet(
|
|
997
|
+
message: message)
|
|
998
|
+
}
|
|
999
|
+
response = addToResponse(response: response, respSet: respSet)
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
@@ -104,8 +104,8 @@ class UtilsSQLStatement {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
class func modifyPair(_ pair: String, from: [String],
|
|
107
|
-
destination: [String],prefix: String) throws -> String {
|
|
108
|
-
|
|
107
|
+
destination: [String], prefix: String) throws -> String {
|
|
108
|
+
|
|
109
109
|
let pattern = #"(\w+)\s*(=|IN|BETWEEN|LIKE)\s*(.+)"#
|
|
110
110
|
|
|
111
111
|
guard let range = pair.range(of: pattern, options: .regularExpression) else {
|
|
@@ -159,79 +159,79 @@ class UtilsSQLStatement {
|
|
|
159
159
|
let modifiedColumn = "\(prefix)\(newColumn)"
|
|
160
160
|
return "\(modifiedColumn) \(mOperator) \(value)"
|
|
161
161
|
}
|
|
162
|
-
/*
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
*/
|
|
162
|
+
/*
|
|
163
|
+
class func addPrefixToWhereClause(_ whereClause: String,
|
|
164
|
+
from: [String],
|
|
165
|
+
destination: [String], prefix: String)
|
|
166
|
+
throws -> String {
|
|
167
|
+
var columnValuePairs: [String]
|
|
168
|
+
if whereClause.contains("AND") {
|
|
169
|
+
if #available(iOS 16.0, *) {
|
|
170
|
+
let subSequenceArray = whereClause.split(separator: "AND")
|
|
171
|
+
columnValuePairs = subSequenceArray.map({ String($0) })
|
|
172
|
+
} else {
|
|
173
|
+
columnValuePairs = whereClause
|
|
174
|
+
.components(separatedBy: "AND")
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
columnValuePairs = [whereClause]
|
|
178
|
+
}
|
|
179
|
+
let modifiedPairs = try columnValuePairs.map({ pair -> String in
|
|
180
|
+
let pattern = #"(\w+)\s*(=|IN|BETWEEN|LIKE)\s*(.+)"#
|
|
181
|
+
|
|
182
|
+
if let range = pair.range(of: pattern, options: .regularExpression) {
|
|
183
|
+
let match = String(pair[range])
|
|
184
|
+
let regex = try NSRegularExpression(pattern: pattern)
|
|
185
|
+
let matchRange = NSRange(match.startIndex..., in: match)
|
|
186
|
+
|
|
187
|
+
if let matchResult = regex.firstMatch(in: match, range: matchRange) {
|
|
188
|
+
|
|
189
|
+
guard let columnRange = Range(matchResult.range(at: 1), in: match) else {
|
|
190
|
+
let msg = "addPrefixToWhereClause: " +
|
|
191
|
+
"columnRange failed "
|
|
192
|
+
throw UtilsSQLStatementError
|
|
193
|
+
.addPrefixToWhereClause(message: msg)
|
|
194
|
+
}
|
|
195
|
+
guard let operatorRange = Range(matchResult.range(at: 2), in: match) else {
|
|
196
|
+
let msg = "addPrefixToWhereClause: " +
|
|
197
|
+
"operatorRange failed "
|
|
198
|
+
throw UtilsSQLStatementError
|
|
199
|
+
.addPrefixToWhereClause(message: msg)
|
|
200
|
+
}
|
|
201
|
+
guard let valueRange = Range(matchResult.range(at: 3), in: match) else {
|
|
202
|
+
let msg = "addPrefixToWhereClause: " +
|
|
203
|
+
"valueRange failed "
|
|
204
|
+
throw UtilsSQLStatementError
|
|
205
|
+
.addPrefixToWhereClause(message: msg)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let column = String(match[columnRange]).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
209
|
+
let mOperator = String(match[operatorRange]).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
210
|
+
let value = String(match[valueRange]).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
211
|
+
|
|
212
|
+
var newColumn = column
|
|
213
|
+
if let index = UtilsSQLStatement
|
|
214
|
+
.findIndexOfStringInArray(column, destination), index != -1 {
|
|
215
|
+
guard let mNewColumn = UtilsSQLStatement
|
|
216
|
+
.getStringAtIndex(from, index) else {
|
|
217
|
+
let msg = "addPrefixToWhereClause: index " +
|
|
218
|
+
"mistmatch "
|
|
219
|
+
throw UtilsSQLStatementError
|
|
220
|
+
.addPrefixToWhereClause(message: msg)
|
|
221
|
+
}
|
|
222
|
+
newColumn = mNewColumn
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let modifiedColumn = "\(prefix)\(newColumn)"
|
|
226
|
+
return "\(modifiedColumn) \(mOperator) \(value)"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return pair
|
|
230
|
+
})
|
|
231
|
+
return modifiedPairs.joined(separator: " AND ")
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
*/
|
|
235
235
|
// MARK: - findIndexOfStringInArray
|
|
236
236
|
|
|
237
237
|
class func findIndexOfStringInArray(_ target: String, _ array: [String]) -> Int? {
|
|
@@ -292,8 +292,7 @@ class UtilsSQLStatement {
|
|
|
292
292
|
let referencedTableRangeInString =
|
|
293
293
|
Range(referencedTableRange, in: sqlStatement),
|
|
294
294
|
let referencedColumnsRangeInString =
|
|
295
|
-
Range(referencedColumnsRange, in: sqlStatement)
|
|
296
|
-
{
|
|
295
|
+
Range(referencedColumnsRange, in: sqlStatement) {
|
|
297
296
|
let referencedTable = String(
|
|
298
297
|
sqlStatement[referencedTableRangeInString])
|
|
299
298
|
let referencedColumns = String(
|
|
@@ -376,48 +375,48 @@ class UtilsSQLStatement {
|
|
|
376
375
|
}
|
|
377
376
|
}
|
|
378
377
|
|
|
379
|
-
/* func processToken(_ token: String) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
378
|
+
/* func processToken(_ token: String) {
|
|
379
|
+
if token.uppercased() == "IN" {
|
|
380
|
+
inClause = true
|
|
381
|
+
} else if inClause && (token.prefix(7).uppercased() == "(VALUES" ||
|
|
382
|
+
token.prefix(8).uppercased() == "( VALUES") {
|
|
383
|
+
inValues = true
|
|
384
|
+
} else if inValues && (token.suffix(2).uppercased() == "))" ||
|
|
385
|
+
token.suffix(3).uppercased() == ") )") {
|
|
386
|
+
inValues = false
|
|
387
|
+
} else if inClause && !inValues && token.prefix(1) == "(" {
|
|
388
|
+
inPar = true
|
|
389
|
+
} else if inClause && !inValues && token.suffix(1) == ")" {
|
|
390
|
+
inPar = false
|
|
391
|
+
inClause = false
|
|
392
|
+
} else if token.uppercased() == "BETWEEN" {
|
|
393
|
+
betweenClause = true
|
|
394
|
+
} else if betweenClause && token.uppercased() == "AND" {
|
|
395
|
+
andClause = true
|
|
396
|
+
} else if operators.contains(token) {
|
|
397
|
+
inOper = true
|
|
398
|
+
} else if token.uppercased() == "LIKE" {
|
|
399
|
+
inLike = true
|
|
400
|
+
} else if token.range(of: "\\b[a-zA-Z]\\w*\\b", options: .regularExpression) != nil
|
|
401
|
+
&& !inClause && (!inValues || !inPar)
|
|
402
|
+
&& !betweenClause && !andClause && !inOper && !inLike
|
|
403
|
+
&& !keywords.contains(token.uppercased()) {
|
|
404
|
+
var mToken = extractString(from: token)
|
|
405
|
+
mToken = removeOperatorsAndFollowing(from: mToken)
|
|
406
|
+
columns.append(mToken)
|
|
407
|
+
} else if token.range(of: "\\b[a-zA-Z]\\w*\\b", options: .regularExpression) != nil
|
|
408
|
+
&& betweenClause && andClause {
|
|
409
|
+
betweenClause = false
|
|
410
|
+
andClause = false
|
|
411
|
+
} else if token.range(of: "\\b[a-zA-Z]\\w*\\b", options: .regularExpression) != nil
|
|
412
|
+
&& inOper {
|
|
413
|
+
inOper = false
|
|
414
|
+
} else if token.range(of: "\\b[a-zA-Z]\\w*\\b", options: .regularExpression) != nil
|
|
415
|
+
&& inLike {
|
|
416
|
+
inLike = false
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
*/
|
|
421
420
|
// swiftlint:disable cyclomatic_complexity
|
|
422
421
|
func processToken(_ token: String) {
|
|
423
422
|
if token.uppercased() == "IN" {
|
|
@@ -538,7 +537,7 @@ class UtilsSQLStatement {
|
|
|
538
537
|
}
|
|
539
538
|
class func processInsertStatement(_ sqlStmt: String, stmt: String) -> SQLStatementInfo {
|
|
540
539
|
if let valuesIndex = stmt.range(of: "VALUES", options: .caseInsensitive)?.lowerBound,
|
|
541
|
-
|
|
540
|
+
let closingParenthesisIndex = stmt
|
|
542
541
|
.range(of: ")", options: .backwards, range: valuesIndex..<stmt.endIndex)?
|
|
543
542
|
.upperBound {
|
|
544
543
|
var mStmt = stmt
|
|
@@ -679,7 +678,7 @@ class UtilsSQLStatement {
|
|
|
679
678
|
if let keysRange = Range(match.range(at: 1), in: whereClause) {
|
|
680
679
|
let keysString = String(whereClause[keysRange])
|
|
681
680
|
let keys = keysString.split(separator: ",").map({
|
|
682
|
-
|
|
681
|
+
String($0.trimmingCharacters(in: .whitespaces)) })
|
|
683
682
|
primaryKeySets.append(keys)
|
|
684
683
|
}
|
|
685
684
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"electron/",
|
|
16
16
|
"CapacitorCommunitySqlite.podspec"
|
|
17
17
|
],
|
|
18
|
-
"author": "
|
|
18
|
+
"author": "Robin Genz <mail@robingenz.dev>",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=16.0.0"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"verify:web": "npm run build",
|
|
44
44
|
"verify:electron": "npm run build-electron",
|
|
45
45
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
46
|
-
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint --
|
|
46
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
47
47
|
"eslint": "eslint . --ext ts",
|
|
48
48
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
49
49
|
"swiftlint": "node-swiftlint",
|
|
@@ -56,26 +56,28 @@
|
|
|
56
56
|
"clean": "rimraf ./dist",
|
|
57
57
|
"watch": "tsc --watch",
|
|
58
58
|
"test": "echo \"No test specified\"",
|
|
59
|
-
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
|
|
59
|
+
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen",
|
|
60
|
+
"release": "standard-version"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@capacitor/android": "
|
|
63
|
-
"@capacitor/cli": "
|
|
64
|
-
"@capacitor/core": "
|
|
65
|
-
"@capacitor/docgen": "
|
|
66
|
-
"@capacitor/ios": "
|
|
67
|
-
"@ionic/eslint-config": "
|
|
68
|
-
"@ionic/prettier-config": "
|
|
69
|
-
"@ionic/swiftlint-config": "
|
|
70
|
-
"@rollup/plugin-commonjs": "
|
|
71
|
-
"@rollup/plugin-node-resolve": "
|
|
72
|
-
"eslint": "
|
|
73
|
-
"prettier": "
|
|
74
|
-
"prettier-plugin-java": "
|
|
75
|
-
"rimraf": "
|
|
76
|
-
"rollup": "
|
|
77
|
-
"
|
|
78
|
-
"
|
|
63
|
+
"@capacitor/android": "6.0.0",
|
|
64
|
+
"@capacitor/cli": "6.0.0",
|
|
65
|
+
"@capacitor/core": "6.0.0",
|
|
66
|
+
"@capacitor/docgen": "0.0.17",
|
|
67
|
+
"@capacitor/ios": "6.0.0",
|
|
68
|
+
"@ionic/eslint-config": "0.4.0",
|
|
69
|
+
"@ionic/prettier-config": "2.0.0",
|
|
70
|
+
"@ionic/swiftlint-config": "1.1.2",
|
|
71
|
+
"@rollup/plugin-commonjs": "20.0.0",
|
|
72
|
+
"@rollup/plugin-node-resolve": "13.0.4",
|
|
73
|
+
"eslint": "8.57.0",
|
|
74
|
+
"prettier": "2.6.2",
|
|
75
|
+
"prettier-plugin-java": "1.6.1",
|
|
76
|
+
"rimraf": "3.0.2",
|
|
77
|
+
"rollup": "2.77.2",
|
|
78
|
+
"standard-version": "9.5.0",
|
|
79
|
+
"swiftlint": "1.0.1",
|
|
80
|
+
"typescript": "4.6.4"
|
|
79
81
|
},
|
|
80
82
|
"peerDependencies": {
|
|
81
83
|
"@capacitor/core": "^6.0.0"
|