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 6eb60161
authored
Apr 17, 2014
by
José Moreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test unit
for #1640
1 parent
25bfe771
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
test/include/findAll.test.js
test/include/findAll.test.js
View file @
6eb6016
...
@@ -821,6 +821,50 @@ describe(Support.getTestDialectTeaser("Include"), function () {
...
@@ -821,6 +821,50 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
})
})
})
it
(
"should be possible to define a belongsTo include as required with child hasMany not required"
,
function
(
done
)
{
var
S
=
this
.
sequelize
,
Address
=
S
.
define
(
'Address'
,
{
'active'
:
DataTypes
.
BOOLEAN
})
,
Street
=
S
.
define
(
'Street'
,
{
'active'
:
DataTypes
.
BOOLEAN
})
,
User
=
S
.
define
(
'User'
,
{
'username'
:
DataTypes
.
STRING
})
// Associate
User
.
belongsTo
(
Address
,
{
foreignKey
:
'addressId'
})
Address
.
hasMany
(
User
,
{
foreignKey
:
'addressId'
})
Address
.
belongsTo
(
Street
,
{
foreignKey
:
'streetId'
})
Street
.
hasMany
(
Address
,
{
foreignKey
:
'streetId'
})
// Sync
S
.
sync
({
force
:
true
}).
success
(
function
()
{
// Create instances
Street
.
create
({
active
:
true
}).
done
(
function
(
err
,
street
){
expect
(
err
).
not
.
to
.
be
.
ok
;
expect
(
street
).
to
.
be
.
ok
Address
.
create
({
active
:
true
,
streetId
:
street
.
id
}).
done
(
function
(
err
,
address
){
expect
(
err
).
not
.
to
.
be
.
ok
;
expect
(
address
).
to
.
be
.
ok
User
.
create
({
username
:
'John'
,
addressId
:
address
.
id
}).
done
(
function
(
err
,
john
){
expect
(
err
).
not
.
to
.
be
.
ok
;
expect
(
john
).
to
.
be
.
ok
// Test
User
.
find
({
where
:
{
username
:
'John'
},
include
:
[
{
model
:
Address
,
include
:
[
{
model
:
Street
}
],
required
:
true
,
where
:
{
active
:
true
}
}
]
}).
done
(
function
(
err
,
john
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
john
.
addresses
).
to
.
have
.
length
(
1
)
done
();
})
})
})
})
})
})
it
(
'should be possible to define a belongsTo include as required with child hasMany with limit'
,
function
(
done
)
{
it
(
'should be possible to define a belongsTo include as required with child hasMany with limit'
,
function
(
done
)
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Group
=
this
.
sequelize
.
define
(
'Group'
,
{
,
Group
=
this
.
sequelize
.
define
(
'Group'
,
{
...
...
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