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 16d3d716
authored
Feb 12, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(): Fix regression with arrays and objects with multiple keys. closes #3107
1 parent
8108099e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletions
changelog.md
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
changelog.md
View file @
16d3d71
# Next
# Next
-
[
BUG
]
Fixed regression with
`DataTypes.ARRAY(DataTypes.STRING(length))`
#3106
-
[
BUG
]
Fixed regression with
`DataTypes.ARRAY(DataTypes.STRING(length))`
#3106
-
[
BUG
]
Fixed regression where
`.or([{key: value}, {key: value, key2: value}])`
would result in 3
`A OR B OR C`
rather than
`A OR (B AND C)`
#3107
# 2.0.1
# 2.0.1
-
[
BUG
]
Fixed issue with empty
`include.where`
-
[
BUG
]
Fixed issue with empty
`include.where`
...
...
lib/dialects/abstract/query-generator.js
View file @
16d3d71
...
@@ -1660,7 +1660,9 @@ module.exports = (function() {
...
@@ -1660,7 +1660,9 @@ module.exports = (function() {
if
(
Array
.
isArray
(
value
))
{
if
(
Array
.
isArray
(
value
))
{
value
=
value
.
map
(
function
(
item
)
{
value
=
value
.
map
(
function
(
item
)
{
return
self
.
whereItemsQuery
(
item
,
options
,
binding
);
var
itemQuery
=
self
.
whereItemsQuery
(
item
,
options
,
' AND '
);
if
(
Object
.
keys
(
item
).
length
>
1
)
itemQuery
=
'('
+
itemQuery
+
')'
;
return
itemQuery
;
}).
filter
(
function
(
item
)
{
}).
filter
(
function
(
item
)
{
return
item
&&
item
.
length
;
return
item
&&
item
.
length
;
});
});
...
...
test/unit/sql/where.test.js
View file @
16d3d71
...
@@ -170,6 +170,17 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
...
@@ -170,6 +170,17 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
default
:
'([equipment] IN (1, 3) OR [muscles] IN (2, 4))'
default
:
'([equipment] IN (1, 3) OR [muscles] IN (2, 4))'
});
});
testsql
(
'$or'
,
[
{
roleName
:
'NEW'
},
{
roleName
:
'CLIENT'
,
type
:
'CLIENT'
}
],
{
default
:
"([roleName] = 'NEW' OR ([roleName] = 'CLIENT' AND [type] = 'CLIENT'))"
});
test
(
"sequelize.or({group_id: 1}, {user_id: 2})"
,
function
()
{
test
(
"sequelize.or({group_id: 1}, {user_id: 2})"
,
function
()
{
expectsql
(
sql
.
whereItemQuery
(
undefined
,
this
.
sequelize
.
or
({
group_id
:
1
},
{
user_id
:
2
})),
{
expectsql
(
sql
.
whereItemQuery
(
undefined
,
this
.
sequelize
.
or
({
group_id
:
1
},
{
user_id
:
2
})),
{
default
:
"([group_id] = 1 OR [user_id] = 2)"
default
:
"([group_id] = 1 OR [user_id] = 2)"
...
...
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