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 77ea2ee1
authored
Jun 23, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: regression with reload() and attributes option, closes #3976
1 parent
2a18502d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
10 deletions
changelog.md
lib/instance.js
test/integration/instance.test.js
changelog.md
View file @
77ea2ee
# 3.3.1
-
[
FIXED
]
regression in
`attributes`
support for 'reload'
[
#3976
](
https://github.com/sequelize/sequelize/issues/3976
)
# 3.3.0
-
[
FIXED
]
Fix
`Promise#nodeify()`
and
`Promise#done()`
not passing CLS context
-
[
FIXED
]
Creating and dropping enums in transaction, only for PostgreSQL
[
#3782
](
https://github.com/sequelize/sequelize/issues/3782
)
...
...
lib/instance.js
View file @
77ea2ee
...
...
@@ -713,21 +713,18 @@ Instance.prototype.save = function(options) {
* @return {Promise<this>}
*/
Instance
.
prototype
.
reload
=
function
(
options
)
{
var
self
=
this
,
where
=
[
this
.
sequelize
.
getQueryInterface
().
quoteTable
(
this
.
Model
.
name
)
+
'.'
+
this
.
sequelize
.
getQueryInterface
().
quoteIdentifier
(
this
.
Model
.
primaryKeyField
)
+
'=?'
,
this
.
get
(
this
.
Model
.
primaryKeyAttribute
,
{
raw
:
true
})
];
options
=
_
.
defaults
(
options
||
{},
{
where
:
where
,
where
:
this
.
where
()
,
limit
:
1
,
include
:
this
.
options
.
include
||
null
});
return
this
.
Model
.
findOne
(
options
).
then
(
function
(
reload
)
{
self
.
set
(
reload
.
dataValues
,
{
raw
:
true
,
reset
:
true
});
}).
return
(
self
);
return
this
.
Model
.
findOne
(
options
).
bind
(
this
).
then
(
function
(
reload
)
{
this
.
set
(
reload
.
dataValues
,
{
raw
:
true
,
reset
:
true
&&
!
options
.
attributes
});
}).
return
(
this
);
};
/*
...
...
test/integration/instance.test.js
View file @
77ea2ee
...
...
@@ -427,6 +427,28 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
it
(
'should support updating a subset of attributes'
,
function
()
{
return
this
.
User
.
create
({
aNumber
:
1
,
bNumber
:
1
,
}).
bind
(
this
).
tap
(
function
(
user
)
{
return
this
.
User
.
update
({
bNumber
:
2
},
{
where
:
{
id
:
user
.
get
(
'id'
)
}
});
}).
then
(
function
(
user
)
{
return
user
.
reload
({
attributes
:
[
'bNumber'
]
});
}).
then
(
function
(
user
)
{
expect
(
user
.
get
(
'aNumber'
)).
to
.
equal
(
1
);
expect
(
user
.
get
(
'bNumber'
)).
to
.
equal
(
2
);
});
});
it
(
'should update read only attributes as well (updatedAt)'
,
function
()
{
var
self
=
this
;
...
...
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