You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2013/10/15 23:23:43 UTC

[jira] [Resolved] (CB-4506) Storage plugin does not handle data type properly

     [ https://issues.apache.org/jira/browse/CB-4506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe Bowser resolved CB-4506.
----------------------------

    Resolution: Fixed

Fixed with org.apache.cordova.websql plugin.

> Storage plugin does not handle data type properly
> -------------------------------------------------
>
>                 Key: CB-4506
>                 URL: https://issues.apache.org/jira/browse/CB-4506
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.9.0
>         Environment: Android 2.3.x, 3.x, 4.x on emulator
> Android 4.x on physical device
>            Reporter: Shingo Toda
>            Assignee: Joe Bowser
>            Priority: Minor
>
> I'm using Cordova 2.9.0.
> In my understanding, when window.openDatabase() is called, if SECURITY_ERR is returned then Storage plugin is used, otherwise browser's WebSQL is used.
> Actually my mobile phone doesn't support WebSQL so Storage plugin is selected, but it seems that all of fetched data from database is converted into String even if it is other data type such as INTEGER, FLOAT.
> The following line in Storage#processResults() converts all data into String. All column value is collected by Cursor#getString(). 
> {code:title=Storage#processResult()}
>             String key = "";
>             String value = "";
>             // Build up JSON result object for each row
>             do {
>                 JSONObject row = new JSONObject();
>                 try {
>                     for (int i = 0; i < colCount; ++i) {
>                         key = cur.getColumnName(i);
>                         value = cur.getString(i);
>                         row.put(key, value);
>                     }
>                     fullresult.put(row);
>                 } catch (JSONException e) {
>                     e.printStackTrace();
>                 }
>             } while (cur.moveToNext());
> {code}
> Since type check methods are provided such as Cursor#getType() (>=HoneyComb) or AbstractWindowedCursor#isLong/String/Float() (<HoneyComb), why don't you use these method to switch proper get method? (isXXX() methods are deprecated from HoneyComb but they still work on Gingerbread!)



--
This message was sent by Atlassian JIRA
(v6.1#6144)