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 1a1467fc
authored
Feb 06, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for .and()/.or() in includes
1 parent
d6329d48
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
test/include.test.js
test/include.test.js
View file @
1a1467f
...
@@ -514,6 +514,112 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -514,6 +514,112 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
})
})
})
describe
.
only
(
'where'
,
function
()
{
it
(
'should support Sequelize.and()'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Item
=
this
.
sequelize
.
define
(
'Item'
,
{
'test'
:
DataTypes
.
STRING
})
User
.
hasOne
(
Item
);
Item
.
belongsTo
(
User
);
this
.
sequelize
.
sync
().
done
(
function
()
{
async
.
auto
({
users
:
function
(
callback
)
{
User
.
bulkCreate
([{},
{},
{}]).
done
(
function
()
{
User
.
findAll
().
done
(
callback
)
})
},
items
:
function
(
callback
)
{
Item
.
bulkCreate
([
{
'test'
:
'abc'
},
{
'test'
:
'def'
},
{
'test'
:
'ghi'
}
]).
done
(
function
()
{
Item
.
findAll
().
done
(
callback
)
})
},
associate
:
[
'users'
,
'items'
,
function
(
callback
,
results
)
{
var
chainer
=
new
Sequelize
.
Utils
.
QueryChainer
()
var
users
=
results
.
users
var
items
=
results
.
items
chainer
.
add
(
users
[
0
].
setItem
(
items
[
0
]))
chainer
.
add
(
users
[
1
].
setItem
(
items
[
1
]))
chainer
.
add
(
users
[
2
].
setItem
(
items
[
2
]))
chainer
.
run
().
done
(
callback
)
}]
},
function
()
{
User
.
findAll
({
include
:
[
{
model
:
Item
,
where
:
Sequelize
.
and
({
test
:
'def'
})}
]}).
done
(
function
(
err
,
result
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
result
.
length
).
to
.
eql
(
1
)
expect
(
result
[
0
].
item
.
test
).
to
.
eql
(
'def'
)
done
()
})
})
})
})
it
(
'should support Sequelize.or()'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Item
=
this
.
sequelize
.
define
(
'Item'
,
{
'test'
:
DataTypes
.
STRING
})
User
.
hasOne
(
Item
);
Item
.
belongsTo
(
User
);
this
.
sequelize
.
sync
().
done
(
function
()
{
async
.
auto
({
users
:
function
(
callback
)
{
User
.
bulkCreate
([{},
{},
{}]).
done
(
function
()
{
User
.
findAll
().
done
(
callback
)
})
},
items
:
function
(
callback
)
{
Item
.
bulkCreate
([
{
'test'
:
'abc'
},
{
'test'
:
'def'
},
{
'test'
:
'ghi'
}
]).
done
(
function
()
{
Item
.
findAll
().
done
(
callback
)
})
},
associate
:
[
'users'
,
'items'
,
function
(
callback
,
results
)
{
var
chainer
=
new
Sequelize
.
Utils
.
QueryChainer
()
var
users
=
results
.
users
var
items
=
results
.
items
chainer
.
add
(
users
[
0
].
setItem
(
items
[
0
]))
chainer
.
add
(
users
[
1
].
setItem
(
items
[
1
]))
chainer
.
add
(
users
[
2
].
setItem
(
items
[
2
]))
chainer
.
run
().
done
(
callback
)
}]
},
function
()
{
User
.
findAll
({
include
:
[
{
model
:
Item
,
where
:
Sequelize
.
or
({
test
:
'def'
},
{
test
:
'abc'
})}
]}).
done
(
function
(
err
,
result
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
result
.
length
).
to
.
eql
(
2
)
done
()
}).
on
(
'sql'
,
function
(
sql
)
{
console
.
log
(
sql
)
})
})
})
})
})
describe
(
'findAndCountAll'
,
function
()
{
describe
(
'findAndCountAll'
,
function
()
{
it
(
'should include associations to findAndCountAll'
,
function
(
done
)
{
it
(
'should include associations to findAndCountAll'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
...
...
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