Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17263] Can't use null arguments with Titanium.Database.DB.execute on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsdb, execute, null, query
Reportercarlo
AssigneeUnknown
Created2014-07-01T12:19:59.000+0000
Updated2018-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.

Comments

  1. Shuo Liang 2014-07-02

    Reproduce this problem on Andriod with both Titanium SDK 3.2.1 and 3.30RC My test case:
       var 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();
       
    Bind value can't be set null for Android platform, but works for iOS

JSON Source