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 8683d792
authored
Jul 28, 2014
by
Ryan Pon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check how to treat array when doing paranoidClause
1 parent
9d774d31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
lib/model.js
test/dao-factory.test.js
lib/model.js
View file @
8683d79
...
...
@@ -1580,12 +1580,23 @@ module.exports = (function() {
options
.
where
+=
' AND '
+
quoteIdentifiedDeletedAtCol
+
' IS NULL '
;
}
else
if
(
Array
.
isArray
(
options
.
where
))
{
// Don't overwrite our explicit deletedAt search value if we provide one
if
(
options
.
where
[
0
].
indexOf
(
deletedAtCol
)
!==
-
1
)
{
return
options
;
// Need to check how the array is being used, as it could be an array
// of string-likes/Dates or an array with objects, hashes, or other
// complex data types
if
(
Utils
.
canTreatArrayAsAnd
(
options
.
where
))
{
// TODO: This is simplifying this case greatly. We actually need all
// the logic from QueryGenerator.getWhereConditions in order to
// properly decide what to do here.
var
whereObj
=
{};
whereObj
[
quoteIdentifiedDeletedAtCol
]
=
null
;
options
.
where
.
push
(
whereObj
);
}
else
{
// Don't overwrite our explicit deletedAt search value if we provide one
if
(
options
.
where
[
0
].
indexOf
(
deletedAtCol
)
!==
-
1
)
{
return
options
;
}
options
.
where
[
0
]
+=
' AND '
+
quoteIdentifiedDeletedAtCol
+
' IS NULL '
;
}
options
.
where
[
0
]
+=
' AND '
+
quoteIdentifiedDeletedAtCol
+
' IS NULL '
;
}
else
{
options
.
where
[
deletedAtCol
]
=
null
;
}
...
...
test/dao-factory.test.js
View file @
8683d79
...
...
@@ -2100,6 +2100,20 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'should not fail when array contains Sequelize.or / and'
,
function
(
done
)
{
this
.
User
.
findAll
({
where
:
[
this
.
sequelize
.
or
({
username
:
'vader'
},
{
username
:
'luke'
}),
this
.
sequelize
.
and
({
id
:
[
1
,
2
,
3
]
})
]
})
.
then
(
function
(
res
)
{
expect
(
res
).
to
.
have
.
length
(
2
)
done
()
})
.
catch
(
function
(
e
)
{
done
(
e
)
})
})
it
(
'should not fail with an include'
,
function
(
done
)
{
this
.
User
.
findAll
({
where
:
[
...
...
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