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
不要怂,就是干,撸起袖子干!
You need to sign in or sign up before continuing.
Commit 1c10d07e
authored
Mar 18, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3351 from calvintwr/master
$not as grouping comparator
2 parents
16d175a1
4efa2a64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
1c10d07
...
...
@@ -1583,6 +1583,7 @@ module.exports = (function() {
var
self
=
this
,
binding
,
outerBinding
,
comparatorMap
,
aliasMap
,
comparator
=
'='
...
...
@@ -1668,9 +1669,14 @@ module.exports = (function() {
}
}
// OR/AND grouping logic
if
(
key
===
'$or'
||
key
===
'$and'
)
{
binding
=
key
===
'$or'
?
' OR '
:
' AND '
;
// OR/AND/NOT grouping logic
if
(
key
===
'$or'
||
key
===
'$and'
||
key
===
'$not'
)
{
binding
=
(
key
===
'$or'
)
?
' OR '
:
' AND '
;
outerBinding
=
''
;
if
(
key
===
'$not'
)
outerBinding
=
'NOT '
;
if
(
Array
.
isArray
(
value
))
{
value
=
value
.
map
(
function
(
item
)
{
...
...
@@ -1683,10 +1689,10 @@ module.exports = (function() {
return
item
&&
item
.
length
;
});
return
value
.
length
?
'('
+
value
.
join
(
binding
)
+
')'
:
undefined
;
return
value
.
length
?
outerBinding
+
'('
+
value
.
join
(
binding
)
+
')'
:
undefined
;
}
else
{
value
=
self
.
whereItemsQuery
(
value
,
options
,
binding
);
return
value
?
'('
+
value
+
')'
:
undefined
;
return
value
?
outerBinding
+
'('
+
value
+
')'
:
undefined
;
}
}
...
...
test/unit/sql/where.test.js
View file @
1c10d07
...
...
@@ -161,7 +161,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
});
});
suite
(
'$and/$or'
,
function
()
{
suite
(
'$and/$or
/$not
'
,
function
()
{
suite
(
'$or'
,
function
()
{
testsql
(
'email'
,
{
$or
:
[
'maker@mhansen.io'
,
'janzeh@gmail.com'
]
...
...
@@ -257,6 +257,18 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
});
});
});
suite
(
'$not'
,
function
()
{
testsql
(
'$not'
,
{
shared
:
1
,
$or
:
{
group_id
:
1
,
user_id
:
2
}
},
{
default
:
"NOT ([shared] = 1 AND ([group_id] = 1 OR [user_id] = 2))"
});
});
});
suite
(
'$gt'
,
function
()
{
...
...
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