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

Commit 35fe16f5 by Sascha Depold

Merge branch 'sislab' of git://github.com/sislab/sequelize into sislab-sislab

2 parents 197a0fb0 6bc272bf
...@@ -159,7 +159,7 @@ module.exports = (function() { ...@@ -159,7 +159,7 @@ module.exports = (function() {
} }
if (options.group) { if (options.group) {
options.group = Utils.addTicks(options.group) options.group = Array.isArray(options.group) ? options.group.map(function(grp){return Utils.addTicks(grp)}).join(', ') : Utils.addTicks(options.group)
query += " GROUP BY <%= group %>" query += " GROUP BY <%= group %>"
} }
......
...@@ -285,7 +285,7 @@ module.exports = (function() { ...@@ -285,7 +285,7 @@ module.exports = (function() {
} }
if(options.group) { if(options.group) {
options.group = addQuotes(options.group) options.group = Array.isArray(options.group) ? options.group.map(function(grp){return addQuotes(grp)}).join(', ') : addQuotes(options.group)
query += " GROUP BY <%= group %>" query += " GROUP BY <%= group %>"
} }
......
...@@ -78,6 +78,14 @@ describe('QueryGenerator', function() { ...@@ -78,6 +78,14 @@ 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"]}],
expectation: "SELECT * FROM `myTable` GROUP BY `name`;",
context: QueryGenerator
}, {
arguments: ['myTable', {group: ["name", "title"]}],
expectation: "SELECT * FROM `myTable` GROUP BY `name`, `title`;",
context: QueryGenerator
}, {
arguments: ['myTable', {group: "name", order: "id DESC"}], arguments: ['myTable', {group: "name", order: "id DESC"}],
expectation: "SELECT * FROM `myTable` GROUP BY `name` ORDER BY id DESC;", expectation: "SELECT * FROM `myTable` GROUP BY `name` ORDER BY id DESC;",
context: QueryGenerator context: QueryGenerator
......
...@@ -72,6 +72,12 @@ describe('QueryGenerator', function() { ...@@ -72,6 +72,12 @@ describe('QueryGenerator', function() {
arguments: ['myTable', {group: "name"}], arguments: ['myTable', {group: "name"}],
expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\";" expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\";"
}, { }, {
arguments: ['myTable', {group: ["name"]}],
expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\";"
}, {
arguments: ['myTable', {group: ["name","title"]}],
expectation: "SELECT * FROM \"myTable\" GROUP BY \"name\", \"title\";"
}, {
arguments: ['myTable', {limit: 10}], arguments: ['myTable', {limit: 10}],
expectation: "SELECT * FROM \"myTable\" LIMIT 10;" expectation: "SELECT * FROM \"myTable\" LIMIT 10;"
}, { }, {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!