cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Bowser (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CB-3047) db.transaction succes callback called on every tx.executeSql on android 4.0.x
Date Tue, 16 Apr 2013 17:51:16 GMT

    [ https://issues.apache.org/jira/browse/CB-3047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13633073#comment-13633073
] 

Joe Bowser edited comment on CB-3047 at 4/16/13 5:50 PM:
---------------------------------------------------------

Android 4.x currently uses shim to implement WebSQL which means that every SQL statement fires
a callback as to whether the SQL statement succeeded or failed.  I recommend not using webSQL
and using WebStorage instead if you want something that's consistent across versions of Android
and across platforms as of 2.7.
                
      was (Author: bowserj):
    Android 4.x currently uses shim to implement WebSQL which means that every SQL statement
fires a callback as to whether the SQL statement succeeded or failed.
                  
> db.transaction succes callback called on every tx.executeSql on android 4.0.x
> -----------------------------------------------------------------------------
>
>                 Key: CB-3047
>                 URL: https://issues.apache.org/jira/browse/CB-3047
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android, CordovaJS
>    Affects Versions: 2.6.0
>         Environment:  Galaxy S2 (4.1.2), Asus Transformer TF101 (4.0.3), Galaxy Tab (4.0.4)
>            Reporter: Daniel Robles Pichardo
>            Assignee: Joe Bowser
>              Labels: newbie
>
> The transaction callback is fired on every executeSql like in this example. But in 2.5.0
is only called only when populate_table ends (end of transaction).
> {code:javascript}
> function save_table(table_data) {
>         console.log(JSON.stringify(table_data));
>         var metadata = table_data.content.meta;
>         var name = metadata.table_name;
>         var fields = metadata.fields_order;
>         var rows = table_data.content.data;
>  
>         var populate_table = function (tx) {
>             tx.executeSql('DROP TABLE IF EXISTS ' + name); // <-- fired HERE
>  
>             var create_smt = 'CREATE TABLE IF NOT EXISTS ' + name +
>                 ' (' + fields.join(', ') + ');';
>  
>             tx.executeSql(create_smt); // <-- fired HERE
>  
>             var placeholders = fields.map(function () {
>                 return '?';
>             });
>             var insert_smt = 'INSERT INTO ' + name +
>                 ' VALUES (' + placeholders.join(', ') + ')';
>  
>             for (var i = 0; i < rows.length; i++) {
>                 tx.executeSql(insert_smt, rows[i]); // <-- fired HERE
>             }
>         };
>  
>         var success = function () {
>             TABLES_DONNE ++;
>             update_progress();
>             if (TABLES_DONNE >= TOTAL_TABLES) {
>                 load_assignments_table();
>             }
>         };
>  
>         ISDS.db.transaction(populate_table, sql_error, success);
>     }
> {code}
> EDIT: I put a wrong version

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