Also check for undefined orderBy
authorBen Thompson <ben@xtuple.com>
Tue, 6 May 2014 17:32:07 +0000 (13:32 -0400)
committerBen Thompson <ben@xtuple.com>
Tue, 6 May 2014 17:32:07 +0000 (13:32 -0400)
lib/orm/source/xt/javascript/data.sql

index 857ee0e..74c3ba0 100644 (file)
@@ -1909,7 +1909,7 @@ select xt.install_js('XT','Data','xtuple', $$
 
       /* Because we query views of views, you can get inconsistent results */
       /* when doing limit and offest queries without an order by. Add a default. */
-      if (limit && offset && !orderBy.length && !clause.orderByColumns) {
+      if (limit && offset && (!orderBy || !orderBy.length) && !clause.orderByColumns) {
         /* We only want this on sql1, not sql2's clause.orderBy. */
         clause.orderByColumns = XT.format('order by t1.%1$I', [pkeyColumn]);
       }