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 d7353be8
authored
Sep 14, 2015
by
Verdier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not inject Model..include in options directly
1 parent
dea73751
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
lib/model.js
test/integration/associations/scope.test.js
lib/model.js
View file @
d7353be
...
@@ -2547,6 +2547,9 @@ Model.$injectScope = function (scope, options) {
...
@@ -2547,6 +2547,9 @@ Model.$injectScope = function (scope, options) {
}
}
return
sameModel
;
return
sameModel
;
}))
{
}))
{
// Do not inject Model.$scope.include directly,
// make a shallow copy (#4470).
scopeInclude
=
_
.
clone
(
scopeInclude
);
options
.
include
.
push
(
scopeInclude
);
options
.
include
.
push
(
scopeInclude
);
}
}
});
});
...
...
test/integration/associations/scope.test.js
View file @
d7353be
...
@@ -26,6 +26,9 @@ describe(Support.getTestDialectTeaser('associations'), function() {
...
@@ -26,6 +26,9 @@ describe(Support.getTestDialectTeaser('associations'), function() {
}
}
});
});
this
.
Post
.
addScope
(
'withComments'
,
{
include
:
[
this
.
Comment
]
});
this
.
Post
.
hasMany
(
this
.
Comment
,
{
this
.
Post
.
hasMany
(
this
.
Comment
,
{
foreignKey
:
'commentable_id'
,
foreignKey
:
'commentable_id'
,
scope
:
{
scope
:
{
...
@@ -141,6 +144,31 @@ describe(Support.getTestDialectTeaser('associations'), function() {
...
@@ -141,6 +144,31 @@ describe(Support.getTestDialectTeaser('associations'), function() {
expect
(
question
.
comments
[
0
].
get
(
'title'
)).
to
.
equal
(
'I am a question comment'
);
expect
(
question
.
comments
[
0
].
get
(
'title'
)).
to
.
equal
(
'I am a question comment'
);
});
});
});
});
it
(
'should make the same query if called multiple time (#4470)'
,
function
()
{
var
self
=
this
;
var
logs
=
[];
var
logging
=
function
(
log
)
{
logs
.
push
(
log
);
};
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
self
.
Post
.
create
();
}).
then
(
function
(
post
)
{
return
post
.
createComment
({
title
:
'I am a post comment'
});
}).
then
(
function
()
{
return
self
.
Post
.
scope
(
'withComments'
).
findAll
({
logging
:
logging
});
}).
then
(
function
()
{
return
self
.
Post
.
scope
(
'withComments'
).
findAll
({
logging
:
logging
});
}).
then
(
function
()
{
expect
(
logs
[
0
]).
to
.
equal
(
logs
[
1
]);
});
});
});
});
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
if
(
Support
.
getTestDialect
()
!==
'sqlite'
)
{
...
...
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