[TIMOB-17263] Can't use null arguments with Titanium.Database.DB.execute on Android
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | db, execute, null, query |
| Reporter | carlo |
| Assignee | Unknown |
| Created | 2014-07-01T12:19:59.000+0000 |
| Updated | 2018-02-28T20:03:12.000+0000 |
Description
var db = Ti.Database.open('test');
var row = db.execute("select ? = ? as testfield", [1,null]);
alert("result: "+row.fieldByName('testfield'));
Works on iOS, "Uncaught Error: the bind value at index 2 is null" on Android.
Reproduce this problem on Andriod with both Titanium SDK 3.2.1 and 3.30RC My test case:
Bind value can't be set null for Android platform, but works for iOSvar db = Ti.Database.open('mydb1Installed'); db.execute('DELETE FROM people'); // no need this line for the first time running db.execute('CREATE TABLE IF NOT EXISTS people (name TEXT, phone_number TEXT, city TEXT)'); var thisName = 'Arthur'; var thisPhoneNo = '1-617-000-0000'; var thisCity = 'Mountain View'; db.execute('INSERT INTO people (name, phone_number, city) VALUES (?, ?, ?)', thisName, thisPhoneNo, thisCity); var personArray = ['Paul','020 7000 0000', null]; db.execute('INSERT INTO people (name, phone_number, city) VALUES (?, ?, ?)', personArray); var rows = db.execute('SELECT rowid,name,phone_number,city FROM people where city is ?', [null]); while (rows.isValidRow()) { Ti.API.info('Person ---> ROWID: ' + rows.fieldByName('rowid') + ', name:' + rows.field(1) + ', phone_number: ' + rows.fieldByName('phone_number') + ', city: ' + rows.field(3)); rows.next(); } db.close(); rows.close();