@capacitor-community/sqlite 3.5.0 → 3.5.1-1
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 +2 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +4 -2
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +8 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsJson.java +33 -0
- package/electron/dist/plugin.js +35 -3
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/Database.swift +4 -1
- package/ios/Plugin/ImportExportJson/ImportFromJson.swift +9 -1
- package/ios/Plugin/Utils/UtilsJson.swift +28 -0
- package/package.json +5 -5
|
@@ -467,7 +467,8 @@ class Database {
|
|
|
467
467
|
if !isExists {
|
|
468
468
|
// check if there are tables with last_modified column
|
|
469
469
|
let isLastModified: Bool = try UtilsJson.isLastModified(mDB: self)
|
|
470
|
-
|
|
470
|
+
let isSqlDeleted: Bool = try UtilsJson.isSqlDeleted(mDB: self)
|
|
471
|
+
if isLastModified && isSqlDeleted {
|
|
471
472
|
let date = Date()
|
|
472
473
|
let syncTime: Int = Int(date.timeIntervalSince1970)
|
|
473
474
|
var stmt: String = "CREATE TABLE IF NOT EXISTS "
|
|
@@ -486,6 +487,8 @@ class Database {
|
|
|
486
487
|
}
|
|
487
488
|
} catch UtilsJsonError.isLastModified(let message) {
|
|
488
489
|
throw DatabaseError.createSyncTable(message: message)
|
|
490
|
+
} catch UtilsJsonError.isSqlDeleted(let message) {
|
|
491
|
+
throw DatabaseError.createSyncTable(message: message)
|
|
489
492
|
} catch UtilsJsonError.tableNotExists(let message) {
|
|
490
493
|
throw DatabaseError.createSyncTable(message: message)
|
|
491
494
|
} catch DatabaseError.executeSQL(let message) {
|
|
@@ -186,12 +186,15 @@ class ImportFromJson {
|
|
|
186
186
|
|
|
187
187
|
// MARK: - ImportFromJson - CreateTableSchema
|
|
188
188
|
|
|
189
|
+
// swiftlint:disable function_body_length
|
|
190
|
+
// swiftlint:disable cyclomatic_complexity
|
|
189
191
|
class func createTableSchema(mSchema: [JsonColumn],
|
|
190
192
|
tableName: String, mode: String)
|
|
191
193
|
-> [String] {
|
|
192
194
|
var statements: [String] = []
|
|
193
195
|
var stmt: String
|
|
194
196
|
var isLastModified: Bool = false
|
|
197
|
+
var isSqlDeleted: Bool = false
|
|
195
198
|
stmt = "CREATE TABLE IF NOT EXISTS "
|
|
196
199
|
stmt.append(tableName)
|
|
197
200
|
stmt.append(" (")
|
|
@@ -201,6 +204,9 @@ class ImportFromJson {
|
|
|
201
204
|
if jSchColumn == "last_modified" {
|
|
202
205
|
isLastModified = true
|
|
203
206
|
}
|
|
207
|
+
if jSchColumn == "sql_deleted" {
|
|
208
|
+
isSqlDeleted = true
|
|
209
|
+
}
|
|
204
210
|
stmt.append(jSchColumn)
|
|
205
211
|
}
|
|
206
212
|
}
|
|
@@ -222,7 +228,7 @@ class ImportFromJson {
|
|
|
222
228
|
}
|
|
223
229
|
stmt.append(");")
|
|
224
230
|
statements.append(stmt)
|
|
225
|
-
if isLastModified {
|
|
231
|
+
if isLastModified && isSqlDeleted {
|
|
226
232
|
// create trigger last_modified associated with the table
|
|
227
233
|
let triggerName: String = tableName + "_trigger_last_modified"
|
|
228
234
|
stmt = "CREATE TRIGGER IF NOT EXISTS "
|
|
@@ -240,6 +246,8 @@ class ImportFromJson {
|
|
|
240
246
|
}
|
|
241
247
|
return statements
|
|
242
248
|
}
|
|
249
|
+
// swiftlint:enable cyclomatic_complexity
|
|
250
|
+
// swiftlint:enable function_body_length
|
|
243
251
|
|
|
244
252
|
// MARK: - ImportFromJson - CreateTableIndexes
|
|
245
253
|
|
|
@@ -18,6 +18,7 @@ enum UtilsJsonError: Error {
|
|
|
18
18
|
case validateTriggers(message: String)
|
|
19
19
|
case validateViews(message: String)
|
|
20
20
|
case isLastModified(message: String)
|
|
21
|
+
case isSqlDeleted(message: String)
|
|
21
22
|
case checkUpdate(message: String)
|
|
22
23
|
case checkValues(message: String)}
|
|
23
24
|
|
|
@@ -81,6 +82,33 @@ class UtilsJson {
|
|
|
81
82
|
return ret
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
// MARK: - ImportFromJson - IsSqlDeleted
|
|
86
|
+
|
|
87
|
+
class func isSqlDeleted(mDB: Database) throws -> Bool {
|
|
88
|
+
var msg: String = "Error SqlDeleted: "
|
|
89
|
+
if !mDB.isDBOpen() {
|
|
90
|
+
msg.append("Database not opened")
|
|
91
|
+
throw UtilsJsonError.isSqlDeleted(message: msg)
|
|
92
|
+
}
|
|
93
|
+
var ret: Bool = false
|
|
94
|
+
do {
|
|
95
|
+
let tableList: [String] = try UtilsDrop.getTablesNames(mDB: mDB)
|
|
96
|
+
for table in tableList {
|
|
97
|
+
let namesTypes: JsonNamesTypes = try getTableColumnNamesTypes(mDB: mDB,
|
|
98
|
+
tableName: table)
|
|
99
|
+
if namesTypes.names.contains("sql_deleted") {
|
|
100
|
+
ret = true
|
|
101
|
+
break
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch UtilsJsonError.getTableColumnNamesTypes(let message) {
|
|
105
|
+
throw UtilsJsonError.isSqlDeleted(message: message)
|
|
106
|
+
} catch UtilsDropError.getTablesNamesFailed(let message) {
|
|
107
|
+
throw UtilsJsonError.isSqlDeleted(message: message)
|
|
108
|
+
}
|
|
109
|
+
return ret
|
|
110
|
+
}
|
|
111
|
+
|
|
84
112
|
// MARK: - ImportFromJson - IsViewExists
|
|
85
113
|
|
|
86
114
|
class func isViewExists(mDB: Database, viewName: String)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-1",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@capacitor/android": "^3.5.
|
|
59
|
-
"@capacitor/core": "^3.5.
|
|
58
|
+
"@capacitor/android": "^3.5.1",
|
|
59
|
+
"@capacitor/core": "^3.5.1",
|
|
60
60
|
"@capacitor/docgen": "^0.0.17",
|
|
61
|
-
"@capacitor/ios": "^3.5.
|
|
61
|
+
"@capacitor/ios": "^3.5.1",
|
|
62
62
|
"@ionic/eslint-config": "^0.3.0",
|
|
63
63
|
"@ionic/prettier-config": "^1.0.1",
|
|
64
64
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
@@ -93,6 +93,6 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"jeep-sqlite": "^1.5.
|
|
96
|
+
"jeep-sqlite": "^1.5.2"
|
|
97
97
|
}
|
|
98
98
|
}
|