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 1aa0c388
authored
Nov 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Bugari/sequelize
into Bugari-master
2 parents
6bf2a1df
ab5f7567
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
test/include/findAll.test.js
test/include/findAll.test.js
View file @
1aa0c38
...
...
@@ -235,6 +235,106 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}
})
it
(
'should accept nested `where` and `limit` at the same time'
,
function
(
done
)
{
var
Product
=
this
.
sequelize
.
define
(
'Product'
,
{
title
:
DataTypes
.
STRING
})
,
Tag
=
this
.
sequelize
.
define
(
'Tag'
,
{
name
:
DataTypes
.
STRING
})
,
ProductTag
=
this
.
sequelize
.
define
(
'ProductTag'
,
{
priority
:
DataTypes
.
INTEGER
})
,
Set
=
this
.
sequelize
.
define
(
'Set'
,
{
title
:
DataTypes
.
STRING
})
Set
.
hasMany
(
Product
)
Product
.
belongsTo
(
Set
)
Product
.
hasMany
(
Tag
,
{
through
:
ProductTag
})
Tag
.
hasMany
(
Product
,
{
through
:
ProductTag
})
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Set
.
bulkCreate
([
{
title
:
'office'
}
])
.
then
(
function
()
{
return
Product
.
bulkCreate
([
{
title
:
'Chair'
},
{
title
:
'Desk'
},
{
title
:
'Dress'
}
])
})
.
then
(
function
()
{
return
Tag
.
bulkCreate
([
{
name
:
'A'
},
{
name
:
'B'
},
{
name
:
'C'
}
]).
done
(
function
()
{
return
Tag
.
findAll
()
})
})
.
then
(
function
()
{
return
Set
.
findAll
()
})
.
then
(
function
(
sets
)
{
return
[
sets
,
Product
.
findAll
()]
})
.
spread
(
function
(
sets
,
products
)
{
return
sets
[
0
].
addProduct
(
products
[
0
])
.
then
(
function
()
{
return
sets
[
0
].
addProduct
(
products
[
1
])
}).
then
(
function
()
{
return
[
sets
,
products
]
})
})
.
spread
(
function
(
sets
,
products
)
{
return
[
sets
,
products
,
Tag
.
findAll
()]
})
.
spread
(
function
(
sets
,
products
,
tags
)
{
return
products
[
0
].
addTag
(
tags
[
0
],
{
priority
:
1
})
.
then
(
function
()
{
return
products
[
0
].
addTag
(
tags
[
1
],
{
priority
:
2
})
})
.
then
(
function
()
{
return
products
[
0
].
addTag
(
tags
[
2
],
{
priority
:
1
})
})
.
then
(
function
()
{
return
products
[
1
].
addTag
(
tags
[
1
],
{
priority
:
2
})
})
.
then
(
function
()
{
return
products
[
2
].
addTag
(
tags
[
1
],
{
priority
:
3
})
})
.
then
(
function
()
{
return
products
[
2
].
addTag
(
tags
[
2
],
{
priority
:
0
})
})
})
.
then
(
function
()
{
return
Set
.
findAll
({
include
:
[
{
model
:
Product
,
include
:
[
{
model
:
Tag
,
where
:
{
name
:
'A'
}
}]
}],
limit
:
1
})
})
.
then
(
function
()
{
done
()
})
.
catch
(
function
(
err
)
{
expect
(
err
).
not
.
to
.
be
.
ok
done
()
})
})
})
it
(
'should support an include with multiple different association types'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Product
=
this
.
sequelize
.
define
(
'Product'
,
{
...
...
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