不要怂,就是干,撸起袖子干!

Commit c03a18e2 by Mick Hansen

Merge branch 'bugfix/whitelist-order-keywords' of https://github.com/seegno/sequ…

…elize into seegno-bugfix/whitelist-order-keywords
2 parents 3f74fec0 a93a3a7e
......@@ -1263,8 +1263,18 @@ module.exports = (function() {
var mainQueryOrder = [];
var subQueryOrder = [];
var validateOrder = function(order) {
if (!_.contains(['ASC', 'DESC'], order.toUpperCase())) {
throw new Error(util.format('Order must be \'ASC\' or \'DESC\', \'%s\' given', order));
}
};
if (Array.isArray(options.order)) {
options.order.forEach(function(t) {
if (Array.isArray(t) && _.size(t) > 1) {
validateOrder(_.last(t));
}
if (subQuery && (Array.isArray(t) && !(t[0] instanceof Model) && !(t[0].model instanceof Model))) {
subQueryOrder.push(this.quote(t, model));
}
......
......@@ -525,7 +525,7 @@ describe(Support.getTestDialectTeaser('Include'), function() {
],
order: [
User.rawAttributes.id,
[Product, 'id']
[Product, 'id', 'ASC']
]
}).done(function(err, user) {
expect(err).not.to.be.ok;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!