we now return the correct type for the rows

This commit is contained in:
Mike 2012-04-09 20:52:27 -04:00
parent 406c5cb8af
commit 2a98efb74b

View File

@ -220,7 +220,6 @@ public class SQLitePlugin extends Plugin {
if (cur.moveToFirst()) { if (cur.moveToFirst()) {
JSONArray fullresult = new JSONArray(); JSONArray fullresult = new JSONArray();
String key = ""; String key = "";
String value = "";
int colCount = cur.getColumnCount(); int colCount = cur.getColumnCount();
// Build up JSON result object for each row // Build up JSON result object for each row
@ -229,8 +228,24 @@ public class SQLitePlugin extends Plugin {
try { try {
for (int i = 0; i < colCount; ++i) { for (int i = 0; i < colCount; ++i) {
key = cur.getColumnName(i); key = cur.getColumnName(i);
value = cur.getString(i); switch(cur.getType (i))
row.put(key, value); {
case Cursor.FIELD_TYPE_NULL:
row.put(key, null);
break;
case Cursor.FIELD_TYPE_INTEGER:
row.put(key, cur.getInt(i));
break;
case Cursor.FIELD_TYPE_FLOAT:
row.put(key, cur.getFloat(i));
break;
case Cursor.FIELD_TYPE_STRING:
row.put(key, cur.getString(i));
break;
case Cursor.FIELD_TYPE_BLOB:
row.put(key, cur.getBlob(i));
break;
}
} }
fullresult.put(row); fullresult.put(row);