Skip to content

Commit

Permalink
Merge pull request #43 from garymathews/MOD-2558
Browse files Browse the repository at this point in the history
fix(android): preserve field type
  • Loading branch information
lokeshchdhry committed Dec 18, 2019
2 parents d85e5fd + 60629bf commit 5d0e906
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.1.0
version: 3.2.0
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: Provides transparent, secure 256-bit AES encryption of SQLite database files.
Expand Down
39 changes: 25 additions & 14 deletions android/src/appcelerator/encrypteddatabase/TiResultSetProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.appcelerator.titanium.util.TiConvert;

import android.database.Cursor;
import net.sqlcipher.AbstractWindowedCursor;
import net.sqlcipher.CrossProcessCursorWrapper;
import net.sqlcipher.SQLException;
import android.os.Build;

Expand Down Expand Up @@ -95,19 +95,30 @@ private Object internalGetField(int index, int type) {
boolean fromString = false;

try {
if (rs instanceof AbstractWindowedCursor) {
AbstractWindowedCursor cursor = (AbstractWindowedCursor) rs;

if (cursor.isFloat(index)) {
result = cursor.getDouble(index);
} else if (cursor.isLong(index)) {
result = cursor.getLong(index);
} else if (cursor.isNull(index)) {
result = null;
} else if (cursor.isBlob(index)) {
result = TiBlob.blobFromData(cursor.getBlob(index));
} else {
fromString = true;
if (rs instanceof CrossProcessCursorWrapper) {
final CrossProcessCursorWrapper cursor = (CrossProcessCursorWrapper) rs;
final int cursorType = cursor.getType(index);

switch (cursorType) {
case Cursor.FIELD_TYPE_NULL:
result = null;
break;
case Cursor.FIELD_TYPE_INTEGER:
// No long field type, longs are set as integer type.
// Using getLong() to preserve accuracy in these cases.
result = cursor.getLong(index);
break;
case Cursor.FIELD_TYPE_FLOAT:
// No double field type, doubles are set as float type.
// Using getDouble() to preserve accuracy in these cases.
result = cursor.getDouble(index);
break;
case Cursor.FIELD_TYPE_BLOB:
result = TiBlob.blobFromData(cursor.getBlob(index));
break;
case Cursor.FIELD_TYPE_STRING:
default:
fromString = true;
}
} else {
fromString = true;
Expand Down

0 comments on commit 5d0e906

Please sign in to comment.