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 e33462aa
authored
Apr 12, 2019
by
Simon Schick
Committed by
Sushant
Apr 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(querying): swap startWith and endsWith operators (#10753)
1 parent
0caf84b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
docs/querying.md
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
docs/querying.md
View file @
e33462a
...
@@ -162,8 +162,8 @@ const Op = Sequelize.Op
...
@@ -162,8 +162,8 @@ const Op = Sequelize.Op
[
Op
.
notLike
]:
'%hat'
// NOT LIKE '%hat'
[
Op
.
notLike
]:
'%hat'
// NOT LIKE '%hat'
[
Op
.
iLike
]:
'%hat'
// ILIKE '%hat' (case insensitive) (PG only)
[
Op
.
iLike
]:
'%hat'
// ILIKE '%hat' (case insensitive) (PG only)
[
Op
.
notILike
]:
'%hat'
// NOT ILIKE '%hat' (PG only)
[
Op
.
notILike
]:
'%hat'
// NOT ILIKE '%hat' (PG only)
[
Op
.
startsWith
]:
'hat'
// LIKE '
%hat
'
[
Op
.
startsWith
]:
'hat'
// LIKE '
hat%
'
[
Op
.
endsWith
]:
'hat'
// LIKE '
hat%
'
[
Op
.
endsWith
]:
'hat'
// LIKE '
%hat
'
[
Op
.
substring
]:
'hat'
// LIKE '%hat%'
[
Op
.
substring
]:
'hat'
// LIKE '%hat%'
[
Op
.
regexp
]:
'^[h|a|t]'
// REGEXP/~ '^[h|a|t]' (MySQL/PG only)
[
Op
.
regexp
]:
'^[h|a|t]'
// REGEXP/~ '^[h|a|t]' (MySQL/PG only)
[
Op
.
notRegexp
]:
'^[h|a|t]'
// NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only)
[
Op
.
notRegexp
]:
'^[h|a|t]'
// NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only)
...
...
lib/dialects/abstract/query-generator.js
View file @
e33462a
...
@@ -2385,10 +2385,10 @@ class QueryGenerator {
...
@@ -2385,10 +2385,10 @@ class QueryGenerator {
return
this
.
_joinKeyValue
(
key
,
value
.
map
(
identifier
=>
this
.
quoteIdentifier
(
identifier
)).
join
(
'.'
),
comparator
,
options
.
prefix
);
return
this
.
_joinKeyValue
(
key
,
value
.
map
(
identifier
=>
this
.
quoteIdentifier
(
identifier
)).
join
(
'.'
),
comparator
,
options
.
prefix
);
case
Op
.
startsWith
:
case
Op
.
startsWith
:
comparator
=
this
.
OperatorMap
[
Op
.
like
];
comparator
=
this
.
OperatorMap
[
Op
.
like
];
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`
%
${
value
}
`
),
comparator
,
options
.
prefix
);
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`
${
value
}
%
`
),
comparator
,
options
.
prefix
);
case
Op
.
endsWith
:
case
Op
.
endsWith
:
comparator
=
this
.
OperatorMap
[
Op
.
like
];
comparator
=
this
.
OperatorMap
[
Op
.
like
];
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`
${
value
}
%
`
),
comparator
,
options
.
prefix
);
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`
%
${
value
}
`
),
comparator
,
options
.
prefix
);
case
Op
.
substring
:
case
Op
.
substring
:
comparator
=
this
.
OperatorMap
[
Op
.
like
];
comparator
=
this
.
OperatorMap
[
Op
.
like
];
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`%
${
value
}
%`
),
comparator
,
options
.
prefix
);
return
this
.
_joinKeyValue
(
key
,
this
.
escape
(
`%
${
value
}
%`
),
comparator
,
options
.
prefix
);
...
...
test/unit/sql/where.test.js
View file @
e33462a
...
@@ -438,8 +438,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
...
@@ -438,8 +438,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
testsql
(
'username'
,
{
testsql
(
'username'
,
{
[
Op
.
startsWith
]:
'swagger'
[
Op
.
startsWith
]:
'swagger'
},
{
},
{
default
:
"[username] LIKE '
%swagger
'"
,
default
:
"[username] LIKE '
swagger%
'"
,
mssql
:
"[username] LIKE N'
%swagger
'"
mssql
:
"[username] LIKE N'
swagger%
'"
});
});
});
});
...
@@ -447,8 +447,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
...
@@ -447,8 +447,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
testsql
(
'username'
,
{
testsql
(
'username'
,
{
[
Op
.
endsWith
]:
'swagger'
[
Op
.
endsWith
]:
'swagger'
},
{
},
{
default
:
"[username] LIKE '
swagger%
'"
,
default
:
"[username] LIKE '
%swagger
'"
,
mssql
:
"[username] LIKE N'
swagger%
'"
mssql
:
"[username] LIKE N'
%swagger
'"
});
});
});
});
...
...
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