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 93a09b73
authored
Jul 21, 2017
by
Chris Kalmar
Committed by
Felix Becker
Jul 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(querygenerator): add parentheses to queries when using ALL with LIKE (#7989)
1 parent
5611a26c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
93a09b7
...
...
@@ -2304,8 +2304,11 @@ const QueryGenerator = {
if
(
escapeValue
)
{
value
=
this
.
escape
(
value
,
field
,
escapeOptions
);
//if ANY is used with like, add parentheses to generate correct query
if
(
escapeOptions
.
acceptStrings
&&
comparator
.
indexOf
(
'ANY'
)
>
comparator
.
indexOf
(
'LIKE'
))
{
// if ANY or ALL is used with like, add parentheses to generate correct query
if
(
escapeOptions
.
acceptStrings
&&
(
comparator
.
indexOf
(
'ANY'
)
>
comparator
.
indexOf
(
'LIKE'
)
||
comparator
.
indexOf
(
'ALL'
)
>
comparator
.
indexOf
(
'LIKE'
)
))
{
value
=
'('
+
value
+
')'
;
}
}
else
if
(
escapeOptions
.
acceptRegExp
)
{
...
...
test/unit/sql/where.test.js
View file @
93a09b7
...
...
@@ -603,11 +603,35 @@ suite(Support.getTestDialectTeaser('SQL'), () => {
});
testsql
(
'userId'
,
{
$like
:
{
$all
:
[
'foo'
,
'bar'
,
'baz'
]
}
},
{
postgres
:
"\"userId\" LIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql
(
'userId'
,
{
$iLike
:
{
$all
:
[
'foo'
,
'bar'
,
'baz'
]
}
},
{
postgres
:
"\"userId\" ILIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql
(
'userId'
,
{
$notLike
:
{
$all
:
[
'foo'
,
'bar'
,
'baz'
]
}
},
{
postgres
:
"\"userId\" NOT LIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql
(
'userId'
,
{
$notILike
:
{
$all
:
[
'foo'
,
'bar'
,
'baz'
]
}
},
{
postgres
:
"\"userId\" NOT ILIKE ALL
ARRAY['foo','bar','baz']
"
postgres
:
"\"userId\" NOT ILIKE ALL
(ARRAY['foo','bar','baz'])
"
});
});
});
...
...
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