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 5a4d2600
authored
May 02, 2020
by
Sushant
Committed by
GitHub
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model.reload): ignore options.where and always use this.where() (#12211)
1 parent
6fb74c8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
lib/model.js
test/integration/instance/reload.test.js
lib/model.js
View file @
5a4d260
...
...
@@ -4049,8 +4049,9 @@ class Model {
* @returns {Promise<Model>}
*/
async
reload
(
options
)
{
options
=
Utils
.
defaults
({},
options
,
{
where
:
this
.
where
(),
options
=
Utils
.
defaults
({
where
:
this
.
where
()
},
options
,
{
include
:
this
.
_options
.
include
||
null
});
...
...
test/integration/instance/reload.test.js
View file @
5a4d260
...
...
@@ -91,6 +91,20 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
});
it
(
'should use default internal where'
,
async
function
()
{
const
user
=
await
this
.
User
.
create
({
username
:
'Balak Bukhara'
});
const
anotherUser
=
await
this
.
User
.
create
({
username
:
'John Smith'
});
const
primaryKey
=
user
.
get
(
'id'
);
await
user
.
reload
();
expect
(
user
.
get
(
'id'
)).
to
.
equal
(
primaryKey
);
// options.where should be ignored
await
user
.
reload
({
where
:
{
id
:
anotherUser
.
get
(
'id'
)
}
});
expect
(
user
.
get
(
'id'
)).
to
.
equal
(
primaryKey
).
and
.
not
.
equal
(
anotherUser
.
get
(
'id'
));
});
it
(
'should update the values on all references to the DAO'
,
function
()
{
return
this
.
User
.
create
({
username
:
'John Doe'
}).
then
(
originalUser
=>
{
return
this
.
User
.
findByPk
(
originalUser
.
id
).
then
(
updater
=>
{
...
...
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