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

Commit 34ed0d70 by Alexandre Joly

'ORDER BY' should come after 'GROUP BY'

1 parent b2184b24
Showing with 7 additions and 7 deletions
......@@ -262,13 +262,6 @@ module.exports = (function() {
query += " WHERE <%= where %>"
}
if(options.order) {
options.order = options.order.replace(/([^ ]+)(.*)/, function(m, g1, g2) {
return QueryGenerator.addQuotes(g1) + g2
})
query += " ORDER BY <%= order %>"
}
if(options.group) {
if (Array.isArray(options.group)) {
options.group = options.group.map(function(grp){
......@@ -281,6 +274,13 @@ module.exports = (function() {
query += " GROUP BY <%= group %>"
}
if(options.order) {
options.order = options.order.replace(/([^ ]+)(.*)/, function(m, g1, g2) {
return QueryGenerator.addQuotes(g1) + g2
})
query += " ORDER BY <%= order %>"
}
if (!(options.include && (options.limit === 1))) {
if (options.limit) {
query += " LIMIT <%= limit %>"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!