@capacitor-community/sqlite 5.6.1-2 → 5.6.1-4

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.
@@ -1197,7 +1197,9 @@ class ExportToJson {
1197
1197
  row.append(val)
1198
1198
  } else if values[pos][names[jpos]] is Int64 && (
1199
1199
  INTEGERAFFINITY.contains(types[jpos].uppercased()) ||
1200
- NUMERICAFFINITY.contains(types[jpos].uppercased())) {
1200
+ INTEGERAFFINITY.contains(types[jpos]
1201
+ .components(separatedBy: "(")[0].uppercased()) ||
1202
+ NUMERICAFFINITY.contains(types[jpos].uppercased())) {
1201
1203
  guard let val = values[pos][names[jpos]] as? Int64
1202
1204
  else {
1203
1205
  throw ExportToJsonError.createValues(
@@ -1206,8 +1208,8 @@ class ExportToJson {
1206
1208
  row.append(val)
1207
1209
  } else if values[pos][names[jpos]] is Int64 && (
1208
1210
  REALAFFINITY.contains(types[jpos].uppercased()) ||
1209
- NUMERICAFFINITY.contains(types[jpos]
1210
- .components(separatedBy: "(")[0].uppercased())) {
1211
+ NUMERICAFFINITY.contains(types[jpos]
1212
+ .components(separatedBy: "(")[0].uppercased())) {
1211
1213
  guard let val = values[pos][names[jpos]] as? Int64
1212
1214
  else {
1213
1215
  throw ExportToJsonError.createValues(
@@ -1217,18 +1219,26 @@ class ExportToJson {
1217
1219
  } else if values[pos][names[jpos]] is Double && (
1218
1220
  REALAFFINITY.contains(types[jpos].uppercased()) ||
1219
1221
  NUMERICAFFINITY.contains(types[jpos]
1220
- .components(separatedBy: "(")[0].uppercased())) {
1222
+ .components(separatedBy: "(")[0].uppercased())) {
1221
1223
  guard let val = values[pos][names[jpos]] as? Double
1222
1224
  else {
1223
1225
  throw ExportToJsonError.createValues(
1224
1226
  message: "Error value must be double")
1225
1227
  }
1226
1228
  row.append(val)
1229
+ } else if values[pos][names[jpos]] is [UInt8] &&
1230
+ BLOBAFFINITY.contains(types[jpos].uppercased()) {
1231
+ guard let val = values[pos][names[jpos]] as? [UInt8]
1232
+ else {
1233
+ throw ExportToJsonError.createValues(
1234
+ message: "Error value must be [UInt8]")
1235
+ }
1236
+ row.append(val)
1227
1237
 
1228
1238
  } else {
1229
1239
  throw ExportToJsonError.createValues(
1230
1240
  message: "Error value is not (string, nsnull," +
1231
- "int64,double")
1241
+ "int64,double,[UInt8]) ")
1232
1242
  }
1233
1243
  }
1234
1244
  return row
@@ -51,7 +51,7 @@ public struct JsonTable: Codable {
51
51
  var schema: [JsonColumn]?
52
52
  var indexes: [JsonIndex]?
53
53
  var triggers: [JsonTrigger]?
54
- var values: [[UncertainValue<String, Int, Double>]]?
54
+ var values: [[UncertainValue<String, Int, Double, [UInt8]>]]?
55
55
 
56
56
  public func show() {
57
57
  print("name: \(name) ")
@@ -141,12 +141,13 @@ public struct JsonTrigger: Codable {
141
141
  print("logic: \(logic) ")
142
142
  }
143
143
  }
144
- public struct UncertainValue<T: Codable, U: Codable, V: Codable>: Codable {
144
+ public struct UncertainValue<T: Codable, U: Codable, V: Codable, W: Codable>: Codable {
145
145
  public var tValue: T?
146
146
  public var uValue: U?
147
147
  public var vValue: V?
148
+ public var wValue: W?
148
149
  public var value: Any? {
149
- return tValue ?? uValue ?? vValue
150
+ return tValue ?? uValue ?? vValue ?? wValue
150
151
  }
151
152
  public init(from decoder: Decoder) throws {
152
153
  let container = try decoder.singleValueContainer()
@@ -155,6 +156,9 @@ public struct UncertainValue<T: Codable, U: Codable, V: Codable>: Codable {
155
156
  if uValue == nil {
156
157
  vValue = try? container.decode(V.self)
157
158
  }
159
+ if vValue == nil {
160
+ wValue = try? container.decode(W.self)
161
+ }
158
162
  }
159
163
  }
160
164
  public struct JsonView: Codable {
@@ -70,15 +70,12 @@ class UtilsBinding {
70
70
  sqlite3_bind_blob(handle, Int32(idx), data.bytes,
71
71
  Int32(data.bytes.count), SQLITETRANSIENT)
72
72
  } else if let value = value {
73
- let isDict = checkTypeDict(from: value)
74
- if isDict {
75
-
76
- let sortedValues = extractSortedValues(from: value as! [String : Int])
73
+ if let dict = value as? [String: Int] {
74
+ let sortedValues = extractSortedValues(from: dict)
77
75
  let data: Data = Data(sortedValues)
78
76
  sqlite3_bind_blob(handle, Int32(idx), data.bytes,
79
- Int32(data.bytes.count), SQLITETRANSIENT)
77
+ Int32(data.bytes.count), SQLITETRANSIENT)
80
78
  }
81
-
82
79
  } else {
83
80
  throw UtilsSQLCipherError.bindFailed
84
81
  }
@@ -374,7 +374,6 @@ class UtilsDelete {
374
374
 
375
375
  class func getCurrentTimeAsInteger() -> Int {
376
376
  let currentTime = Date().timeIntervalSince1970
377
- print(">>>> in getCurrentTimeAsInteger currentTime: \(currentTime)")
378
377
  return Int(currentTime)
379
378
  }
380
379
 
@@ -191,7 +191,7 @@ class UtilsJson {
191
191
 
192
192
  class func checkColumnTypes (
193
193
  mDB: Database, types: [String],
194
- values: [UncertainValue<String, Int, Double>]) -> Bool {
194
+ values: [UncertainValue<String, Int, Double, [UInt8]>]) -> Bool {
195
195
  var isRetType: Bool = true
196
196
  for ipos in 0..<values.count {
197
197
  isRetType = UtilsJson.isType(
@@ -204,7 +204,7 @@ class UtilsJson {
204
204
  // MARK: - ImportFromJson - IsType
205
205
 
206
206
  class func isType(stype: String,
207
- avalue: UncertainValue<String, Int, Double>)
207
+ avalue: UncertainValue<String, Int, Double, [UInt8]>)
208
208
  -> Bool {
209
209
  var ret: Bool = false
210
210
  // swiftlint:disable force_unwrapping
@@ -266,7 +266,7 @@ class UtilsJson {
266
266
  // MARK: - ImportFromJson - GetValuesFromRow
267
267
 
268
268
  class func getValuesFromRow(
269
- rowValues: [ UncertainValue<String, Int, Double>]) -> [Any] {
269
+ rowValues: [ UncertainValue<String, Int, Double, [UInt8]>]) -> [Any] {
270
270
  var retArray: [Any] = []
271
271
  for ipos in 0..<rowValues.count {
272
272
  let value = rowValues[ipos].value
@@ -354,7 +354,7 @@ class UtilsJson {
354
354
 
355
355
  class func checkRowValidity(
356
356
  mDB: Database, jsonNamesTypes: JsonNamesTypes,
357
- row: [UncertainValue<String, Int, Double>], pos: Int,
357
+ row: [UncertainValue<String, Int, Double, [UInt8]>], pos: Int,
358
358
  tableName: String) throws {
359
359
  if jsonNamesTypes.names.count != row.count {
360
360
  let message: String = """
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.6.1-2",
3
+ "version": "5.6.1-4",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",