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

Commit 7fddb51e by Sascha Depold

Merge pull request #328 from cmingxu/master

switch position for options.order and options.group
2 parents 1b06bbaa d5711e32
...@@ -178,15 +178,16 @@ module.exports = (function() { ...@@ -178,15 +178,16 @@ module.exports = (function() {
query += " WHERE <%= where %>" query += " WHERE <%= where %>"
} }
if(options.order) {
query += " ORDER BY <%= order %>"
}
if(options.group) { if(options.group) {
options.group = Utils.addTicks(options.group) options.group = Utils.addTicks(options.group)
query += " GROUP BY <%= group %>" query += " GROUP BY <%= group %>"
} }
if(options.order) {
query += " ORDER BY <%= order %>"
}
if(options.limit && !(options.include && (options.limit === 1))) { if(options.limit && !(options.include && (options.limit === 1))) {
if(options.offset) { if(options.offset) {
query += " LIMIT <%= offset %>, <%= limit %>" query += " LIMIT <%= offset %>, <%= limit %>"
......
...@@ -74,6 +74,10 @@ describe('QueryGenerator', function() { ...@@ -74,6 +74,10 @@ describe('QueryGenerator', function() {
expectation: "SELECT * FROM `myTable` GROUP BY `name`;", expectation: "SELECT * FROM `myTable` GROUP BY `name`;",
context: QueryGenerator context: QueryGenerator
}, { }, {
arguments: ['myTable', {group: "name", order: "id DESC"}],
expectation: "SELECT * FROM `myTable` GROUP BY `name` ORDER BY id DESC;",
context: QueryGenerator
}, {
arguments: ['myTable', {limit: 10}], arguments: ['myTable', {limit: 10}],
expectation: "SELECT * FROM `myTable` LIMIT 10;", expectation: "SELECT * FROM `myTable` LIMIT 10;",
context: QueryGenerator context: QueryGenerator
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!