cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shingo Toda (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CB-4506) Storage plugin does not handle data type properly
Date Tue, 06 Aug 2013 07:14:47 GMT

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

Shingo Toda updated CB-4506:
----------------------------

    Description: 
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!)



  was:
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(). 

~~~
            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());
~~~

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!)



    
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message