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 e33d2bdc
authored
Jun 21, 2020
by
Sushant
Committed by
GitHub
Jun 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(reload): include default scope (#12399)
1 parent
5611ef0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletions
lib/model.js
test/integration/instance/reload.test.js
lib/model.js
View file @
e33d2bd
...
...
@@ -4043,7 +4043,7 @@ class Model {
options
=
Utils
.
defaults
({
where
:
this
.
where
()
},
options
,
{
include
:
this
.
_options
.
include
||
null
include
:
this
.
_options
.
include
||
undefined
});
const
reloaded
=
await
this
.
constructor
.
findOne
(
options
);
...
...
test/integration/instance/reload.test.js
View file @
e33d2bd
...
...
@@ -301,5 +301,36 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
const
leTeam
=
await
leTeam0
.
reload
();
expect
(
leTeam
.
Players
).
to
.
have
.
length
(
1
);
});
it
(
'should inject default scope when reloading'
,
async
function
()
{
const
Bar
=
this
.
sequelize
.
define
(
'Bar'
,
{
name
:
DataTypes
.
TEXT
});
const
Foo
=
this
.
sequelize
.
define
(
'Foo'
,
{
name
:
DataTypes
.
TEXT
},
{
defaultScope
:
{
include
:
[{
model
:
Bar
}]
}
});
Bar
.
belongsTo
(
Foo
);
Foo
.
hasMany
(
Bar
);
await
this
.
sequelize
.
sync
();
const
foo
=
await
Foo
.
create
({
name
:
'foo'
});
await
foo
.
createBar
({
name
:
'bar'
});
const
fooFromFind
=
await
Foo
.
findByPk
(
foo
.
id
);
expect
(
fooFromFind
.
Bars
).
to
.
be
.
ok
;
expect
(
fooFromFind
.
Bars
[
0
].
name
).
to
.
equal
(
'bar'
);
await
foo
.
reload
();
expect
(
foo
.
Bars
).
to
.
be
.
ok
;
expect
(
foo
.
Bars
[
0
].
name
).
to
.
equal
(
'bar'
);
});
});
});
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