Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 7229ccb9
authored
Sep 23, 2017
by
Yu Qi
Committed by
Sushant
Sep 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(query-generator): options.group should be quoted (#8326)
1 parent
79485c3c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
lib/dialects/abstract/query-generator.js
test/unit/dialects/mysql/query-generator.test.js
test/unit/dialects/postgres/query-generator.test.js
test/unit/dialects/sqlite/query-generator.test.js
lib/dialects/abstract/query-generator.js
View file @
7229ccb
...
...
@@ -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
{
...
...
test/unit/dialects/mysql/query-generator.test.js
View file @
7229ccb
...
...
@@ -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'
,
...
...
test/unit/dialects/postgres/query-generator.test.js
View file @
7229ccb
...
...
@@ -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\";'
...
...
test/unit/dialects/sqlite/query-generator.test.js
View file @
7229ccb
...
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment