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 cf2b16e8
authored
Oct 27, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(include): omit properties in findSeperate that messes with how tables are aliases, closes #4605
1 parent
d8d639ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletions
lib/model.js
test/integration/include/seperate.test.js
lib/model.js
View file @
cf2b16e
...
@@ -1426,7 +1426,7 @@ Model.$findSeparate = function(results, options) {
...
@@ -1426,7 +1426,7 @@ Model.$findSeparate = function(results, options) {
return
include
.
association
.
get
(
results
,
_
.
assign
(
return
include
.
association
.
get
(
results
,
_
.
assign
(
{},
{},
_
.
omit
(
options
,
'include'
,
'attributes'
,
'order'
,
'where'
,
'limit'
,
'plain'
),
_
.
omit
(
options
,
'include'
,
'attributes'
,
'order'
,
'where'
,
'limit'
,
'plain'
),
include
_
.
omit
(
include
,
'parent'
,
'association'
,
'as'
)
)).
then
(
function
(
map
)
{
)).
then
(
function
(
map
)
{
results
.
forEach
(
function
(
result
)
{
results
.
forEach
(
function
(
result
)
{
result
.
set
(
result
.
set
(
...
...
test/integration/include/seperate.test.js
View file @
cf2b16e
...
@@ -231,6 +231,61 @@ if (current.dialect.supports.groupedLimit) {
...
@@ -231,6 +231,61 @@ if (current.dialect.supports.groupedLimit) {
});
});
});
});
it
(
'should work having a separate include between a parent and child include'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Project
=
this
.
sequelize
.
define
(
'Project'
)
,
Company
=
this
.
sequelize
.
define
(
'Company'
)
,
Task
=
this
.
sequelize
.
define
(
'Task'
,
{})
,
sqlSpy
=
sinon
.
spy
();
Company
.
Users
=
Company
.
hasMany
(
User
,
{
as
:
'users'
});
User
.
Tasks
=
User
.
hasMany
(
Task
,
{
as
:
'tasks'
});
Task
.
Project
=
Task
.
belongsTo
(
Project
,
{
as
:
'project'
});
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Promise
.
join
(
Company
.
create
({
id
:
1
,
users
:
[
{
tasks
:
[
{
project
:
{}},
{
project
:
{}},
{
project
:
{}}
]
}
]
},
{
include
:
[
{
association
:
Company
.
Users
,
include
:
[
{
association
:
User
.
Tasks
,
include
:
[
Task
.
Project
]}
]}
]
})
).
then
(
function
()
{
return
Company
.
findAll
({
include
:
[
{
association
:
Company
.
Users
,
include
:
[
{
association
:
User
.
Tasks
,
separate
:
true
,
include
:
[
Task
.
Project
]}
]}
],
order
:
[
[
'id'
,
'ASC'
]
],
logging
:
sqlSpy
});
}).
then
(
function
(
companies
)
{
expect
(
sqlSpy
).
to
.
have
.
been
.
calledTwice
;
expect
(
companies
[
0
].
users
[
0
].
tasks
[
0
].
project
).
to
.
be
.
ok
;
});
});
});
it
(
'should run two nested hasMany association in a separate queries'
,
function
()
{
it
(
'should run two nested hasMany association in a separate queries'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
var
User
=
this
.
sequelize
.
define
(
'User'
,
{})
,
Project
=
this
.
sequelize
.
define
(
'Project'
,
{})
,
Project
=
this
.
sequelize
.
define
(
'Project'
,
{})
...
...
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