@capacitor-community/sqlite 5.0.1 → 5.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.
@@ -8,6 +8,7 @@ import static android.database.Cursor.FIELD_TYPE_STRING;
8
8
 
9
9
  import android.content.Context;
10
10
  import android.content.SharedPreferences;
11
+ import android.os.Build;
11
12
  import android.util.Log;
12
13
  import androidx.sqlite.db.SimpleSQLiteQuery;
13
14
  import androidx.sqlite.db.SupportSQLiteDatabase;
@@ -22,6 +23,7 @@ import java.io.File;
22
23
  import java.text.SimpleDateFormat;
23
24
  import java.util.ArrayList;
24
25
  import java.util.Arrays;
26
+ import java.util.Base64;
25
27
  import java.util.Collections;
26
28
  import java.util.Date;
27
29
  import java.util.Dictionary;
@@ -795,7 +797,12 @@ public class Database {
795
797
  row.put(colName, c.getDouble(index));
796
798
  break;
797
799
  case FIELD_TYPE_BLOB:
798
- row.put(colName, c.getBlob(index));
800
+ // row.put(colName, c.getBlob(index));
801
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
802
+ row.put(colName, Base64.getEncoder().encodeToString(c.getBlob(index)));
803
+ } else {
804
+ row.put(colName, JSONObject.NULL);
805
+ }
799
806
  break;
800
807
  case FIELD_TYPE_NULL:
801
808
  row.put(colName, JSONObject.NULL);
@@ -909,13 +909,15 @@ 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
- let data = sqlite3_column_blob(handle, index)
913
- let size = sqlite3_column_bytes(handle, index)
914
- let val = NSData(bytes: data, length: Int(size))
915
- // Convert to string
916
- let strVal: String = String(decoding: val,
917
- as: UTF8.self)
918
- rowData[String(cString: name)] = strVal
912
+ if let dataBlob = sqlite3_column_blob(handle, index){
913
+ let dataBlobLength = sqlite3_column_bytes(handle,index)
914
+ let data = Data(bytes: dataBlob,
915
+ count:Int(dataBlobLength))
916
+ rowData[String(cString: name)] = data.base64EncodedString()
917
+ } else {
918
+ rowData[String(cString: name)] = NSNull()
919
+ }
920
+
919
921
  case SQLITE_TEXT:
920
922
  let buffer = sqlite3_column_text(handle, index)
921
923
  if let mBuffer = buffer {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "5.0.1",
3
+ "version": "5.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",