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 04062312
authored
Sep 04, 2013
by
Domas Lapinskas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix searching for rows where attribute is in array of values, test
1 parent
1b222915
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
lib/dialects/postgres/query-generator.js
test/dao-factory.test.js
lib/dialects/postgres/query-generator.js
View file @
0406231
...
@@ -565,16 +565,15 @@ module.exports = (function() {
...
@@ -565,16 +565,15 @@ module.exports = (function() {
if
(
Array
.
isArray
(
value
))
{
if
(
Array
.
isArray
(
value
))
{
if
(
value
.
length
===
0
)
{
value
=
[
null
]
}
if
(
value
.
length
===
0
)
{
value
=
[
null
]
}
var
col
=
null
;
// Special conditions for searching within an array column type
// Special conditions for searching within an array column type
var
_realKey
=
key
.
split
(
'.'
).
pop
()
var
_realKey
=
key
.
split
(
'.'
).
pop
()
if
(
!!
factory
&&
!!
factory
.
rawAttributes
[
_realKey
])
{
if
(
!!
factory
&&
!!
factory
.
rawAttributes
[
_realKey
])
{
var
col
=
factory
.
rawAttributes
[
_realKey
]
col
=
factory
.
rawAttributes
[
_realKey
]
}
if
((
!!
col
.
type
&&
col
.
type
.
match
(
/
\[\]
$/
)
!==
null
)
||
(
col
.
toString
().
match
(
/
\[\]
$/
)
!==
null
))
{
if
(
col
&&
((
!!
col
.
type
&&
col
.
type
.
match
(
/
\[\]
$/
)
!==
null
)
||
(
col
.
toString
().
match
(
/
\[\]
$/
)
!==
null
)))
{
_value
=
'ARRAY['
+
value
.
map
(
this
.
escape
).
join
(
','
)
+
']::'
+
(
!!
col
.
type
?
col
.
type
:
col
.
toString
())
_value
=
'ARRAY['
+
value
.
map
(
this
.
escape
).
join
(
','
)
+
']::'
+
(
!!
col
.
type
?
col
.
type
:
col
.
toString
())
result
.
push
([
_key
,
_value
].
join
(
" && "
))
result
.
push
([
_key
,
_value
].
join
(
" && "
))
}
}
else
{
}
else
{
_value
=
"("
+
value
.
map
(
this
.
escape
).
join
(
','
)
+
")"
_value
=
"("
+
value
.
map
(
this
.
escape
).
join
(
','
)
+
")"
result
.
push
([
_key
,
_value
].
join
(
" IN "
))
result
.
push
([
_key
,
_value
].
join
(
" IN "
))
...
...
test/dao-factory.test.js
View file @
0406231
...
@@ -1064,6 +1064,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1064,6 +1064,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
(
'should be able to find rows where attribute is in a list of values'
,
function
()
{
this
.
User
.
findAll
({
where
:
{
username
:
[
'boo'
,
'boo2'
]
}
}).
success
(
function
(
users
){
expect
(
users
).
to
.
have
.
length
(
2
);
});
})
it
(
'should be able to find a row using like'
,
function
(
done
)
{
it
(
'should be able to find a row using like'
,
function
(
done
)
{
this
.
User
.
findAll
({
this
.
User
.
findAll
({
where
:
{
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