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

Commit 7229ccb9 by Yu Qi Committed by Sushant

fix(query-generator): options.group should be quoted (#8326)

1 parent 79485c3c
......@@ -1138,7 +1138,7 @@ const QueryGenerator = {
// Add GROUP BY to sub or main query
if (options.group) {
options.group = Array.isArray(options.group) ? options.group.map(t => this.quote(t, model)).join(', ') : options.group;
options.group = Array.isArray(options.group) ? options.group.map(t => this.quote(t, model)).join(', ') : this.quote(options.group, model);
if (subQuery) {
subQueryItems.push(' GROUP BY ' + options.group);
} else {
......
......@@ -261,9 +261,9 @@ if (dialect === 'mysql') {
context: QueryGenerator,
needsSequelize: true
}, {
title: 'single string argument is not quoted',
title: 'single string argument should be quoted',
arguments: ['myTable', {group: 'name'}],
expectation: 'SELECT * FROM `myTable` GROUP BY name;',
expectation: 'SELECT * FROM `myTable` GROUP BY `name`;',
context: QueryGenerator
}, {
arguments: ['myTable', { group: ['name'] }],
......@@ -291,7 +291,7 @@ if (dialect === 'mysql') {
needsSequelize: true
}, {
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
}, {
title: 'HAVING clause works with where-like hash',
......
......@@ -358,9 +358,9 @@ if (dialect.match(/^postgres/)) {
context: QueryGenerator,
needsSequelize: true
}, {
title: 'single string argument is not quoted',
title: 'single string argument should be quoted',
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\";'
......
......@@ -251,9 +251,9 @@ if (dialect === 'sqlite') {
context: QueryGenerator,
needsSequelize: true
}, {
title: 'single string argument is not quoted',
title: 'single string argument should be quoted',
arguments: ['myTable', {group: 'name'}],
expectation: 'SELECT * FROM `myTable` GROUP BY name;',
expectation: 'SELECT * FROM `myTable` GROUP BY `name`;',
context: QueryGenerator
}, {
arguments: ['myTable', {group: ['name']}],
......@@ -285,7 +285,7 @@ if (dialect === 'sqlite') {
context: QueryGenerator
}, {
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
}, {
title: 'HAVING clause works with where-like hash',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!