Closed pawelrychlik closed 6 years ago
and by workaround I don't mean writing a plaintext query.
This is a bug, thank you for reporting. I have a lot of projects on my plate right now, so a test case + a pull request would be awesome. :)
Any updates on this MR?
@nolanlawson ,
Looks like this issue is reproducing again.
In jsonArrayToStringArray
method all the placeholder values are converting to string:
https://github.com/nolanlawson/cordova-plugin-sqlite-2/blob/959d53a1825940935fb1df5497355916eca639a9/src/android/SQLitePlugin.java#L311-L313
Then all stringified values are passing into the bindAllArguments
function and as result the bindArgs[i] == null
expression is always falsy.
https://github.com/nolanlawson/cordova-plugin-sqlite-2/blob/959d53a1825940935fb1df5497355916eca639a9/src/android/SQLitePlugin.java#L340-L348
As result null values are bindings using tatement.bindString(i + 1, bindArgs[i]);
expression.
@platov Thank you for reporting! Do you have a test case or a suggested PR to fix?
@platov @nolanlawson - Not sure if this is still an issue for anyone, but I just ran into this as well. I've added a PR that resolves the issue on my side.
The plugin seems to use the bindAllArgsAsStrings() method for binding arguments to the SQL query. https://github.com/nolanlawson/cordova-plugin-sqlite-2/blob/master/src/android/SQLitePlugin.java#L112
Android documentation indicates that the method takes a String array of bind args, none of which must be null. https://developer.android.com/reference/android/database/sqlite/SQLiteProgram.html#bindAllArgsAsStrings(java.lang.String[])
Apparently in consequence, whenever my query arguments contain a javascript
null
, the value ends up persisted as a"null"
string. (I'm running the following code, and then Iadb pull
the database file and look up the values).Can you confirm? Is there any workaround for this? I'm using 1.0.4 on android 5.1.