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 22e55f9c
authored
Apr 01, 2014
by
Matt Broadstone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add two tests for Sequelize.or and Sequelize.and using object notation
1 parent
6501dca6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
test/dao-factory/and-or-where.test.js
test/dao-factory/and-or-where.test.js
View file @
22e55f9
...
...
@@ -110,6 +110,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'allows nesting of Sequelize.or using object notation'
,
function
(
done
)
{
this
.
User
.
find
({
where
:
Sequelize
.
and
(
Sequelize
.
or
({
username
:
{
eq
:
"foo"
}},
{
username
:
{
eq
:
"bar"
}}),
Sequelize
.
or
({
id
:
{
eq
:
1
}},
{
id
:
{
eq
:
4
}})
)
}).
on
(
'sql'
,
function
(
sql
)
{
var
expectation
=
({
mysql
:
"WHERE ((`User`.`username` = 'foo' OR `User`.`username` = 'bar') AND (`User`.`id` = 1 OR `User`.`id` = 4)) LIMIT 1"
,
sqlite
:
"WHERE ((`User`.`username` = 'foo' OR `User`.`username` = 'bar') AND (`User`.`id` = 1 OR `User`.`id` = 4)) LIMIT 1"
,
postgres
:
'WHERE (("User"."username" = \'foo\' OR "User"."username" = \'bar\') AND ("User"."id" = 1 OR "User"."id" = 4)) LIMIT 1'
,
mariadb
:
"WHERE ((`User`.`username` = 'foo' OR `User`.`username` = 'bar') AND (`User`.`id` = 1 OR `User`.`id` = 4)) LIMIT 1"
})[
Support
.
getTestDialect
()]
if
(
!
expectation
)
{
console
.
log
(
sql
)
throw
new
Error
(
'Undefined expectation for '
+
Support
.
getTestDialect
())
}
expect
(
sql
).
to
.
contain
(
expectation
)
done
()
})
})
it
(
'allows nesting of Sequelize.and'
,
function
(
done
)
{
this
.
User
.
find
({
where
:
Sequelize
.
or
(
Sequelize
.
and
(
"1=1"
,
"2=2"
),
Sequelize
.
and
(
"3=3"
,
"4=4"
)
)
...
...
@@ -119,6 +141,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'allows nesting of Sequelize.and using object notation'
,
function
(
done
)
{
this
.
User
.
find
({
where
:
Sequelize
.
or
(
Sequelize
.
and
({
username
:
{
eq
:
"foo"
}},
{
username
:
{
eq
:
"bar"
}}),
Sequelize
.
and
({
id
:
{
eq
:
1
}},
{
id
:
{
eq
:
4
}})
)
}).
on
(
'sql'
,
function
(
sql
)
{
var
expectation
=
({
mysql
:
"WHERE ((`User`.`username` = 'foo' AND `User`.`username` = 'bar') OR (`User`.`id` = 1 AND `User`.`id` = 4)) LIMIT 1"
,
sqlite
:
"WHERE ((`User`.`username` = 'foo' AND `User`.`username` = 'bar') OR (`User`.`id` = 1 AND `User`.`id` = 4)) LIMIT 1"
,
postgres
:
'WHERE (("User"."username" = \'foo\' AND "User"."username" = \'bar\') OR ("User"."id" = 1 AND "User"."id" = 4)) LIMIT 1'
,
mariadb
:
"WHERE ((`User`.`username` = 'foo' AND `User`.`username` = 'bar') OR (`User`.`id` = 1 AND `User`.`id` = 4)) LIMIT 1"
})[
Support
.
getTestDialect
()]
if
(
!
expectation
)
{
console
.
log
(
sql
)
throw
new
Error
(
'Undefined expectation for '
+
Support
.
getTestDialect
())
}
expect
(
sql
).
to
.
contain
(
expectation
)
done
()
})
})
if
(
dialect
!==
'postgres'
)
{
it
(
'still allows simple arrays lookups'
,
function
(
done
)
{
this
.
User
.
find
({
...
...
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