/* swap out the attribute in the array for the one with the prepended natural key */
index = parameter.attribute.indexOf(attribute);
parameter.attribute.splice(index, 1);
- parameter.attribute.push(attribute + "." + naturalKey);
+ parameter.attribute.splice(index, 0, attribute + "." + naturalKey);
}
}
});
});
});
+ it('should correctly fix a long list of natural key attributes', function (done) {
+ var sql = 'select xt.js_init();select xt.get($${"nameSpace":"XM","type":"IncidentListItem","query":{"orderBy":[{"attribute":"priorityOrder"},{"attribute":"updated","descending":true},{"attribute":"number","descending":true,"numeric":true}],"rowOffset":0,"rowLimit":50,"parameters":[{"attribute":["number","description","status","category","severity","priority","resolution","project"],"operator":"MATCHES","value":"Certify"},{"attribute":["owner.username","assignedTo.username"],"operator":"","isCharacteristic":false,"value":"admin"}]},"username":"admin","encryptionKey":"this is any content"}$$);';
+
+ datasource.query(sql, creds, function (err, res) {
+ var results;
+ assert.isNull(err);
+ assert.equal(1, res.rowCount, JSON.stringify(res.rows));
+ results = JSON.parse(res.rows[1].get);
+ assert.isNumber(results.data.length);
+ done();
+ });
+ });
+
+
+
// T&E
//select xt.js_init(true);select xt.get($${"nameSpace":"XM","type":"ItemRelation","query":{"parameters":[{"attribute":"projectExpenseMethod","operator":"=","value":"E"},{"attribute":"isActive","value":true},{"attribute":"number","operator":"BEGINS_WITH","value":"pro","keySearch":false}],"orderBy":[{"attribute":"number"}],"rowLimit":1},"username":"admin","encryptionKey":"this is any content"}$$)