issue #23323: bugfix natural key correction
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Sat, 19 Apr 2014 02:30:09 +0000 (22:30 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Sat, 19 Apr 2014 02:30:09 +0000 (22:30 -0400)
lib/orm/source/xt/javascript/data.sql
test/database/joins.js

index 4c7bd92..8395978 100644 (file)
@@ -127,7 +127,7 @@ select xt.install_js('XT','Data','xtuple', $$
               /* 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);
             }
           }
         });
index 80c8ee1..484c4da 100644 (file)
@@ -297,6 +297,21 @@ var _ = require("underscore"),
       });
     });
 
+    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"}$$)