@capacitor-community/sqlite 5.0.2 → 5.0.3-2.test1

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.
@@ -16,6 +16,7 @@ export default {
16
16
  '@capacitor/core',
17
17
  'electron',
18
18
  '@journeyapps/sqlcipher',
19
+ 'sqlite3',
19
20
  'path',
20
21
  'fs',
21
22
  'os',
@@ -802,6 +802,31 @@ enum CapacitorSQLiteError: Error {
802
802
  val.append(obj)
803
803
  } else if value is NSNull {
804
804
  val.append(value)
805
+ } else if let obj = value as? [String: Any] {
806
+ if var keys = Array(obj.keys) as? [String] {
807
+ if #available(iOS 15.0, *) {
808
+ keys.sort(using: .localizedStandard)
809
+ var valuesArr: [UInt8] = []
810
+ for key in keys {
811
+ if let mVal = obj[key] {
812
+ if let iVal = mVal as? Int {
813
+ valuesArr.append(UInt8(iVal))
814
+ } else {
815
+ let msg: String = "Error in reading buffer"
816
+ throw CapacitorSQLiteError.failed(message: msg)
817
+ }
818
+ } else {
819
+ let msg: String = "Error in reading buffer"
820
+ throw CapacitorSQLiteError.failed(message: msg)
821
+ }
822
+ }
823
+ val.append(valuesArr)
824
+ } else {
825
+ let msg: String = "Error buffer sorted not implemented"
826
+ throw CapacitorSQLiteError.failed(message: msg)
827
+
828
+ }
829
+ }
805
830
  } else {
806
831
  let msg: String = "Not a SQL type"
807
832
  throw CapacitorSQLiteError.failed(message: msg)
@@ -0,0 +1,13 @@
1
+ //
2
+ // Array.swift
3
+ // CapacitorCommunitySqlite
4
+ //
5
+ // Created by Quéau Jean Pierre on 10/06/2023.
6
+ //
7
+ import Foundation
8
+
9
+ extension Array where Element == UInt8 {
10
+ var data: Data {
11
+ return Data(self)
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ //
2
+ // Data.swift
3
+ // CapacitorCommunitySqlite
4
+ //
5
+ // Created by Quéau Jean Pierre on 10/06/2023.
6
+ //
7
+ import Foundation
8
+
9
+ extension Data {
10
+ var bytes: [UInt8] {
11
+ return [UInt8](self)
12
+ }
13
+ }
@@ -34,6 +34,7 @@ class UtilsBinding {
34
34
  }
35
35
  return message
36
36
  }
37
+ // swiftlint:disable cyclomatic_complexity
37
38
  class func bind( handle: OpaquePointer?, value: Any?, idx: Int)
38
39
  throws {
39
40
  if value == nil {
@@ -64,9 +65,14 @@ class UtilsBinding {
64
65
  var bInt: Int32 = Int32(0)
65
66
  if value {bInt = Int32(1)}
66
67
  sqlite3_bind_int(handle, Int32(idx), Int32(bInt))
68
+ } else if let value = value as? [UInt8] {
69
+ let data: Data = Data(value)
70
+ sqlite3_bind_blob(handle, Int32(idx), data.bytes,
71
+ Int32(data.bytes.count), SQLITETRANSIENT)
67
72
  } else {
68
73
  throw UtilsSQLCipherError.bindFailed
69
74
  }
70
75
 
71
76
  }
77
+ // swiftlint:enable cyclomatic_complexity
72
78
  }
@@ -909,11 +909,12 @@ class UtilsSQLCipher {
909
909
  let val: Double = sqlite3_column_double(handle, index)
910
910
  rowData[String(cString: name)] = val
911
911
  case SQLITE_BLOB:
912
- if let dataBlob = sqlite3_column_blob(handle, index){
913
- let dataBlobLength = sqlite3_column_bytes(handle,index)
912
+ if let dataBlob = sqlite3_column_blob(handle, index) {
913
+ let dataBlobLength = sqlite3_column_bytes(handle, index)
914
914
  let data = Data(bytes: dataBlob,
915
- count:Int(dataBlobLength))
916
- rowData[String(cString: name)] = data.base64EncodedString()
915
+ count: Int(dataBlobLength))
916
+ // rowData[String(cString: name)] = data.base64EncodedString()
917
+ rowData[String(cString: name)] = data.bytes
917
918
  } else {
918
919
  rowData[String(cString: name)] = NSNull()
919
920
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.0.2",
3
+ "version": "5.0.3-2.test1",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",