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 8c6c7740
authored
Feb 20, 2016
by
Brendon Boshell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
: [] should also return no data
1 parent
b7180e64
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletions
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
8c6c774
...
@@ -2005,13 +2005,19 @@ var QueryGenerator = {
...
@@ -2005,13 +2005,19 @@ var QueryGenerator = {
});
});
// $or: [] should return no data.
// $or: [] should return no data.
if
(
key
===
'$or'
&&
value
.
length
===
0
)
{
// $not of no restriction should also return no data
if
((
key
===
'$or'
||
key
===
'$not'
)
&&
value
.
length
===
0
)
{
return
'0 = 1'
;
return
'0 = 1'
;
}
}
return
value
.
length
?
outerBinding
+
'('
+
value
.
join
(
binding
)
+
')'
:
undefined
;
return
value
.
length
?
outerBinding
+
'('
+
value
.
join
(
binding
)
+
')'
:
undefined
;
}
else
{
}
else
{
value
=
self
.
whereItemsQuery
(
value
,
options
,
binding
);
value
=
self
.
whereItemsQuery
(
value
,
options
,
binding
);
if
((
key
===
'$or'
||
key
===
'$not'
)
&&
!
value
)
{
return
'0 = 1'
;
}
return
value
?
outerBinding
+
'('
+
value
+
')'
:
undefined
;
return
value
?
outerBinding
+
'('
+
value
+
')'
:
undefined
;
}
}
}
}
...
...
test/unit/sql/where.test.js
View file @
8c6c774
...
@@ -253,6 +253,10 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
...
@@ -253,6 +253,10 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
default
:
"0 = 1"
default
:
"0 = 1"
});
});
testsql
(
'$or'
,
{},
{
default
:
"0 = 1"
});
test
(
"sequelize.or()"
,
function
()
{
test
(
"sequelize.or()"
,
function
()
{
expectsql
(
sql
.
whereItemQuery
(
undefined
,
this
.
sequelize
.
or
()),
{
expectsql
(
sql
.
whereItemQuery
(
undefined
,
this
.
sequelize
.
or
()),
{
default
:
"0 = 1"
default
:
"0 = 1"
...
@@ -323,6 +327,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
...
@@ -323,6 +327,14 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
},
{
},
{
default
:
'NOT ([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))'
default
:
'NOT ([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))'
});
});
testsql
(
'$not'
,
[],
{
default
:
"0 = 1"
});
testsql
(
'$not'
,
{},
{
default
:
"0 = 1"
});
});
});
});
});
...
...
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