Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-366] Titanium.Database.execute should support indexed arguments in an array

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-07-25T13:04:32.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, arguments, database, execute, ios, patch
ReporterJohann Richard
AssigneeNeeraj Gupta
Created2011-04-15T02:28:01.000+0000
Updated2012-07-28T16:33:46.000+0000

Description

.execute(sql, args) currently does not support .execute(string, array), which would come in very handy in certain cases. As I understand, the Desktop version already supports that way of calling execute, at least when I read the comments in Ticket 146 (https://appcelerator.lighthouseapp.com/projects/25719/tickets/146">https://appcelerator.lighthouseapp.com/projects/25719/tickets/146) in Titanium Desktop. So it should be doable.

Attachments

FileDateSize
execute.patch2011-04-15T02:28:02.000+0000839

Comments

  1. Johann Richard 2011-04-15

    And here's a (possible) patch to implement this behaviour:

       diff --git a/iphone/modules/DatabaseModule/DatabaseModule.m b/iphone/modules/DatabaseModule/DatabaseModule.m
       index 33702c0..24b901a 100644
       --- a/iphone/modules/DatabaseModule/DatabaseModule.m
       +++ b/iphone/modules/DatabaseModule/DatabaseModule.m
       @@ -293,7 +293,8 @@
                       "remove:function(){Ti.Database._RMDB(this._TOKEN);},"
                       "execute:function(query){"
                           "var args=[];"
       -                   "for(var i=1;i<arguments.length;i++){args.push(arguments[i]);}"
       +                   "for(var i=1;i<arguments.length;i++){if((arguments[i]).constructor == Array){"
       +                   "args.concat(arguments[i]);} else {args.push(arguments[i]);}}"
                           "var comm=Ti.Database._EXEDB(this._TOKEN,query,args);this.rowsAffected=comm.rowsAffected;this.lastInsertRowId=comm.lastRow;"
                           "var res={_TOKEN:comm.token,"
                               "fields:comm.fields,rowCount:comm.rowCount,values:comm.values,"
       

    -- maybe you want it to be even more robust but it should actually implement more or less the behaviour of the Desktop variant of Titanium. At least my tests on the iPhone plus the DB-related Unit tests in the titanium_mobile "Titanium" App did not show any isses w/ that patch when I custom built the SDK.

  2. Stephen Tramer 2011-04-15

    Need to discuss in R&D for feature parity, but if this exists in Desktop, then it should probably exist for mobile.

  3. Ping Wang 2012-07-25

    This is already fixed. See the doc [here](http://docs.appcelerator.com/titanium/2.1/#!/api/Titanium.Database.DB-method-execute).

JSON Source