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 db1733c8
authored
Apr 28, 2015
by
James Wernicke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved readability. Removed unneeded parentheses from query.
1 parent
306aa49a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
lib/dialects/abstract/query-generator.js
test/unit/sql/where.test.js
lib/dialects/abstract/query-generator.js
View file @
db1733c
...
@@ -1737,7 +1737,6 @@ module.exports = (function() {
...
@@ -1737,7 +1737,6 @@ module.exports = (function() {
}
}
// Setup keys and comparators
// Setup keys and comparators
var
any
;
if
(
Array
.
isArray
(
value
)
&&
fieldType
instanceof
DataTypes
.
ARRAY
)
{
if
(
Array
.
isArray
(
value
)
&&
fieldType
instanceof
DataTypes
.
ARRAY
)
{
value
=
this
.
escape
(
value
,
field
);
value
=
this
.
escape
(
value
,
field
);
}
else
if
(
value
&&
(
value
.
$in
||
value
.
$notIn
))
{
}
else
if
(
value
&&
(
value
.
$in
||
value
.
$notIn
))
{
...
@@ -1767,17 +1766,16 @@ module.exports = (function() {
...
@@ -1767,17 +1766,16 @@ module.exports = (function() {
value
=
(
value
.
$between
||
value
.
$notBetween
).
map
(
function
(
item
)
{
value
=
(
value
.
$between
||
value
.
$notBetween
).
map
(
function
(
item
)
{
return
self
.
escape
(
item
);
return
self
.
escape
(
item
);
}).
join
(
' AND '
);
}).
join
(
' AND '
);
}
else
if
(
value
&&
((
value
.
$like
&&
(
any
=
value
.
$like
.
$any
)
&&
(
comparator
=
'LIKE ANY'
))
||
(
value
.
$iLike
&&
(
any
=
value
.
$iLike
.
$any
)
&&
(
comparator
=
'ILIKE ANY'
))
||
(
value
.
$notLike
&&
(
any
=
value
.
$notLike
.
$any
)
&&
(
comparator
=
'NOT LIKE ANY'
))
||
(
value
.
$notILike
&&
(
any
=
value
.
$notILike
.
$any
)
&&
(
comparator
=
'NOT ILIKE ANY'
))))
{
value
=
'('
+
self
.
escape
(
any
)
+
')'
;
}
else
{
}
else
{
if
(
_
.
isPlainObject
(
value
))
{
if
(
_
.
isPlainObject
(
value
))
{
_
.
forOwn
(
value
,
function
(
item
,
key
)
{
_
.
forOwn
(
value
,
function
(
item
,
key
)
{
if
(
comparatorMap
[
key
])
{
if
(
comparatorMap
[
key
])
{
comparator
=
comparatorMap
[
key
];
comparator
=
comparatorMap
[
key
];
value
=
item
;
value
=
item
;
if
(
_
.
isPlainObject
(
value
)
&&
value
.
$any
){
comparator
+=
' ANY'
;
value
=
value
.
$any
;
}
}
}
});
});
}
}
...
...
test/unit/sql/where.test.js
View file @
db1733c
...
@@ -430,28 +430,28 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
...
@@ -430,28 +430,28 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
$any
:
[
'foo'
,
'bar'
,
'baz'
]
$any
:
[
'foo'
,
'bar'
,
'baz'
]
}
}
},
{
},
{
postgres
:
"\"userId\" LIKE ANY
(ARRAY['foo','bar','baz'])
"
postgres
:
"\"userId\" LIKE ANY
ARRAY['foo','bar','baz']
"
});
});
testsql
(
'userId'
,
{
testsql
(
'userId'
,
{
$iLike
:
{
$iLike
:
{
$any
:
[
'foo'
,
'bar'
,
'baz'
]
$any
:
[
'foo'
,
'bar'
,
'baz'
]
}
}
},
{
},
{
postgres
:
"\"userId\" ILIKE ANY
(ARRAY['foo','bar','baz'])
"
postgres
:
"\"userId\" ILIKE ANY
ARRAY['foo','bar','baz']
"
});
});
testsql
(
'userId'
,
{
testsql
(
'userId'
,
{
$notLike
:
{
$notLike
:
{
$any
:
[
'foo'
,
'bar'
,
'baz'
]
$any
:
[
'foo'
,
'bar'
,
'baz'
]
}
}
},
{
},
{
postgres
:
"\"userId\" NOT LIKE ANY
(ARRAY['foo','bar','baz'])
"
postgres
:
"\"userId\" NOT LIKE ANY
ARRAY['foo','bar','baz']
"
});
});
testsql
(
'userId'
,
{
testsql
(
'userId'
,
{
$notILike
:
{
$notILike
:
{
$any
:
[
'foo'
,
'bar'
,
'baz'
]
$any
:
[
'foo'
,
'bar'
,
'baz'
]
}
}
},
{
},
{
postgres
:
"\"userId\" NOT ILIKE ANY
(ARRAY['foo','bar','baz'])
"
postgres
:
"\"userId\" NOT ILIKE ANY
ARRAY['foo','bar','baz']
"
});
});
});
});
});
});
...
...
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