Support placeholders in WebSQL storage shim SQL query strings
-------------------------------------------------------------

                 Key: CB-309
                 URL: https://issues.apache.org/jira/browse/CB-309
             Project: Apache Callback
          Issue Type: New Feature
          Components: Android, CordovaJS
    Affects Versions: 1.4.0, 1.5.0
         Environment: Android 2.3 emulator
            Reporter: Filip Maj
            Assignee: Joe Bowser
            Priority: Minor


Migrated from an issue that existed on github.com/cordova/cordova-android. 
Probably needs investigation/confirmation still. The placeholder {{?}} tokens 
in SQL query strings, which get properly interpolated into whatever types you 
pass in to the arguments array, when used in our Android polyfill on certain 
Android devices, does not work as expected.

{code}
function getAutoCompleteData(response, term){
  var db = window.openDatabase("data", "1.0", "data", 1000000);
  App.term = term;
  db.transaction(autocompleteDB, autocompleteDbError, autocompleteDbSuccess);
}

function autocompleteDB(tx) {
  tx.executeSql("SELECT * FROM auto where name like '%?%'", 
  [App.term], success,error);
}
{code}

Returns error:

{code}
I/System.out(356): Storage.executeSql(): Error=bind or column index out of 
range: handle 0x562508
{code}

I checked source code for 1.3.0 and found what it just has no support for 
placeholders.

----

Simon then asked: What version of Android are you using? Most versions of 
PhoneGap/Cordova are using the built in websql functionality.

----

Response: This not depend of Android version. I just checked source code here 
https://github.com/cordova/cordova-android/blob/master/framework/src/com/phonegap/Storage.java
 in function executeSql and found that is uses placeholders only for isDDL 
querys.

isDDL true only for CREATE, TRUNCATE, DROP, ALTER. My query uses SELECT ;)

----

Simon then asked: What I am saying to you is that code is not executed for most 
versions of Android including 2.1, 2.2, 2.3, 4.0. For some Android versions 3.X 
there is a bug where window.openDatabase() fails so we are forced to fall back 
on the code we wrote in Storage.java. Otherwise we are able to take advantage 
of the built in websql functionality in the WebView.

So I ask again, what version of Android are you running on?

----

Response: Ok. Android 2.3. Tested in android emulator. If '?' replaced by 
App.term value - everything works as expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to