Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2640] $or operator doesn't properly work in ACS custom objects

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-01-17T07:18:06.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator CLI
Labelsacs
Reporterfarid fadaie
AssigneeRitu Agrawal
Created2013-01-19T19:18:19.000+0000
Updated2016-03-08T07:41:44.000+0000

Description

You cannot really use $or in queries on custom objects. Something like: where = { '$or' : [{ name : 'dbb' }, {name : 'abc'}] } doesn't really return anything meaningful. Depending on what the query is, it sometimes returns the objects that match one of the conditions (and not the other one) and sometimes returns nothing (an empty array). When you use any of the conditions individually, they work fine (not with $or).

Comments

  1. Pedro Enrique 2013-04-04

    "$or" is not a parameter according to our documentation. http://cloud.appcelerator.com/docs/api/v1/custom_objects/query
  2. Ritu Agrawal 2014-01-17

    We have not been able to reproduce this issue with custom objects. It is also possible that this issue was fixed after it was reported. Here is the query that I used to verify that this functionality works fine.
       Cloud.Objects.query({
           classname: 'car',
           page: 1,
           per_page: 10,
           where: {
               // color: 'blue'
               '$or' : [{color : 'red'}, {color : 'black'}]
           }
       }, function (e) {
           if (e.success) {
               alert('Success:\n' +
                   'Count: ' + e.car.length);
               for (var i = 0; i < e.car.length; i++) {
                   var car = e.car[i];
                   alert('id: ' + car.id + '\n' +
                       'make: ' + car.make + '\n' +
                       'color: ' + car.color + '\n' +
                       'year: ' + car.year + '\n' +
                       'created_at: ' + car.created_at);
               }
           } else {
               alert('Error:\n' +
                   ((e.error && e.message) || JSON.stringify(e)));
           }
       });
       

JSON Source