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 335efd6d
authored
Jan 22, 2018
by
Jorrit Schippers
Committed by
Sushant
Jan 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(selectQuery): don't add empty HAVING clause (#8931)
1 parent
a4a0f883
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
lib/dialects/abstract/query-generator.js
test/unit/dialects/mysql/query-generator.test.js
lib/dialects/abstract/query-generator.js
View file @
335efd6
...
...
@@ -1159,10 +1159,12 @@ const QueryGenerator = {
// Add HAVING to sub or main query
if
(
options
.
hasOwnProperty
(
'having'
))
{
options
.
having
=
this
.
getWhereConditions
(
options
.
having
,
tableName
,
model
,
options
,
false
);
if
(
subQuery
)
{
subQueryItems
.
push
(
' HAVING '
+
options
.
having
);
}
else
{
mainQueryItems
.
push
(
' HAVING '
+
options
.
having
);
if
(
options
.
having
)
{
if
(
subQuery
)
{
subQueryItems
.
push
(
' HAVING '
+
options
.
having
);
}
else
{
mainQueryItems
.
push
(
' HAVING '
+
options
.
having
);
}
}
}
...
...
test/unit/dialects/mysql/query-generator.test.js
View file @
335efd6
...
...
@@ -417,6 +417,28 @@ if (dialect === 'mysql') {
arguments
:
[
'myTable'
,
{
where
:
{
field
:
{
$notRegexp
:
'^[h|a|t]'
}}}],
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`field` NOT REGEXP '^[h|a|t]';"
,
context
:
QueryGenerator
},
{
title
:
'Empty having'
,
arguments
:
[
'myTable'
,
function
()
{
return
{
having
:
{}
};
}],
expectation
:
'SELECT * FROM `myTable`;'
,
context
:
QueryGenerator
,
needsSequelize
:
true
},
{
title
:
'Having in subquery'
,
arguments
:
[
'myTable'
,
function
()
{
return
{
subQuery
:
true
,
tableAs
:
'test'
,
having
:
{
creationYear
:
{
[
Operators
.
gt
]:
2002
}
}
};
}],
expectation
:
'SELECT `test`.* FROM (SELECT * FROM `myTable` AS `test` HAVING `creationYear` > 2002) AS `test`;'
,
context
:
QueryGenerator
,
needsSequelize
:
true
}
],
...
...
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