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 5af6097e
authored
Feb 23, 2014
by
Overlook Motel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for include all
1 parent
1e1a10b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
test/dao-factory/findAll.test.js
test/dao-factory/findAll.test.js
View file @
5af6097
...
...
@@ -830,6 +830,123 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
describe
(
'include all'
,
function
()
{
beforeEach
(
function
(
done
)
{
var
self
=
this
self
.
Continent
=
this
.
sequelize
.
define
(
'Continent'
,
{
name
:
Sequelize
.
STRING
})
self
.
Country
=
this
.
sequelize
.
define
(
'Country'
,
{
name
:
Sequelize
.
STRING
})
self
.
Industry
=
this
.
sequelize
.
define
(
'Industry'
,
{
name
:
Sequelize
.
STRING
})
self
.
Person
=
this
.
sequelize
.
define
(
'Person'
,
{
name
:
Sequelize
.
STRING
,
lastName
:
Sequelize
.
STRING
})
self
.
Continent
.
hasMany
(
self
.
Country
)
self
.
Country
.
belongsTo
(
self
.
Continent
)
self
.
Country
.
hasMany
(
self
.
Industry
)
self
.
Industry
.
hasMany
(
self
.
Country
)
self
.
Country
.
hasMany
(
self
.
Person
)
self
.
Person
.
belongsTo
(
self
.
Country
)
self
.
Country
.
hasMany
(
self
.
Person
,
{
as
:
'Residents'
,
foreignKey
:
'CountryResidentId'
})
self
.
Person
.
belongsTo
(
self
.
Country
,
{
as
:
'CountryResident'
,
foreignKey
:
'CountryResidentId'
})
async
.
forEach
([
self
.
Continent
,
self
.
Country
,
self
.
Industry
,
self
.
Person
],
function
(
model
,
callback
)
{
model
.
sync
({
force
:
true
}).
done
(
callback
)
},
function
()
{
async
.
parallel
({
europe
:
function
(
callback
)
{
self
.
Continent
.
create
({
name
:
'Europe'
}).
done
(
callback
)},
england
:
function
(
callback
)
{
self
.
Country
.
create
({
name
:
'England'
}).
done
(
callback
)},
coal
:
function
(
callback
)
{
self
.
Industry
.
create
({
name
:
'Coal'
}).
done
(
callback
)},
bob
:
function
(
callback
)
{
self
.
Person
.
create
({
name
:
'Bob'
,
lastName
:
'Becket'
}).
done
(
callback
)}
},
function
(
err
,
r
)
{
if
(
err
)
throw
err
_
.
forEach
(
r
,
function
(
item
,
itemName
)
{
self
[
itemName
]
=
item
})
async
.
parallel
([
function
(
callback
)
{
self
.
england
.
setContinent
(
self
.
europe
).
done
(
callback
)},
function
(
callback
)
{
self
.
england
.
addIndustry
(
self
.
coal
).
done
(
callback
)},
function
(
callback
)
{
self
.
bob
.
setCountry
(
self
.
england
).
done
(
callback
)},
function
(
callback
)
{
self
.
bob
.
setCountryResident
(
self
.
england
).
done
(
callback
)}
],
function
(
err
)
{
if
(
err
)
throw
err
done
()
})
})
})
})
it
(
'includes all associations'
,
function
(
done
)
{
this
.
Country
.
findAll
({
include
:
[
{
all
:
true
}
]
}).
done
(
function
(
err
,
countries
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
countries
).
to
.
exist
expect
(
countries
[
0
]).
to
.
exist
expect
(
countries
[
0
].
continent
).
to
.
exist
expect
(
countries
[
0
].
industries
).
to
.
exist
expect
(
countries
[
0
].
persons
).
to
.
exist
expect
(
countries
[
0
].
residents
).
to
.
exist
done
()
})
})
it
(
'includes specific type of association'
,
function
(
done
)
{
this
.
Country
.
findAll
({
include
:
[
{
all
:
'BelongsTo'
}
]
}).
done
(
function
(
err
,
countries
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
countries
).
to
.
exist
expect
(
countries
[
0
]).
to
.
exist
expect
(
countries
[
0
].
continent
).
to
.
exist
expect
(
countries
[
0
].
industries
).
not
.
to
.
exist
expect
(
countries
[
0
].
persons
).
not
.
to
.
exist
expect
(
countries
[
0
].
residents
).
not
.
to
.
exist
done
()
})
})
it
(
'utilises specified attributes'
,
function
(
done
)
{
this
.
Country
.
findAll
({
include
:
[
{
all
:
'HasMany'
,
attributes
:
[
'name'
]
}
]
}).
done
(
function
(
err
,
countries
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
countries
).
to
.
exist
expect
(
countries
[
0
]).
to
.
exist
expect
(
countries
[
0
].
industries
).
to
.
exist
expect
(
countries
[
0
].
persons
).
to
.
exist
expect
(
countries
[
0
].
persons
[
0
]).
to
.
exist
expect
(
countries
[
0
].
persons
[
0
].
name
).
not
.
to
.
be
.
undefined
expect
(
countries
[
0
].
persons
[
0
].
lastName
).
to
.
be
.
undefined
expect
(
countries
[
0
].
residents
).
to
.
exist
expect
(
countries
[
0
].
residents
[
0
]).
to
.
exist
expect
(
countries
[
0
].
residents
[
0
].
name
).
not
.
to
.
be
.
undefined
expect
(
countries
[
0
].
residents
[
0
].
lastName
).
to
.
be
.
undefined
done
()
})
})
it
(
'is over-ruled by specified include'
,
function
(
done
)
{
this
.
Country
.
findAll
({
include
:
[
{
all
:
true
},
{
model
:
this
.
Continent
,
attributes
:
[]
}
]
}).
done
(
function
(
err
,
countries
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
countries
).
to
.
exist
expect
(
countries
[
0
]).
to
.
exist
expect
(
countries
[
0
].
continent
).
to
.
exist
expect
(
countries
[
0
].
continent
.
name
).
to
.
be
.
undefined
done
()
})
})
it
(
'includes all nested associations'
,
function
(
done
)
{
this
.
Continent
.
findAll
({
include
:
[
{
all
:
true
,
nested
:
true
}
]
}).
done
(
function
(
err
,
continents
)
{
expect
(
err
).
not
.
to
.
be
.
ok
expect
(
continents
).
to
.
exist
expect
(
continents
[
0
]).
to
.
exist
expect
(
continents
[
0
].
countries
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
]).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
industries
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
persons
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
residents
).
to
.
exist
expect
(
continents
[
0
].
countries
[
0
].
continent
).
not
.
to
.
exist
done
()
})
})
})
})
describe
(
'order by eager loaded tables'
,
function
()
{
...
...
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