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 39a4bd03
authored
Jan 08, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mbroadst-broken-updates'
2 parents
07b1dfd6
c7671687
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
changelog.md
lib/instance.js
test/instance/update.test.js
changelog.md
View file @
39a4bd0
...
...
@@ -9,6 +9,7 @@
-
[
BUG
]
Fixed bad SQL when updating a JSON attribute with a different
`field`
-
[
BUG
]
Fixed issue with creating and updating values of a
`DataTypes.ARRAY(DataTypes.JSON)`
attribute
-
[
BUG
]
`Model.bulkCreate([{}], {returning: true})`
will now correctly result in instances with primary key values.
-
[
BUG
]
`instance.save()`
with
`fields: []`
(as a result of
`.changed()`
being
`[]`
) will no result in a noop instead of an empty update query.
#### Backwards compatability changes
-
`instance.update()`
using default fields will now automatically also save and validate values provided via
`beforeUpdate`
hooks
...
...
lib/instance.js
View file @
39a4bd0
...
...
@@ -617,6 +617,8 @@ module.exports = (function() {
});
}
}).
then
(
function
()
{
if
(
!
options
.
fields
.
length
)
return
this
;
return
self
.
QueryInterface
[
query
].
apply
(
self
.
QueryInterface
,
args
)
.
then
(
function
(
result
)
{
// Transfer database generated values (defaults, autoincrement, etc)
...
...
test/instance/update.test.js
View file @
39a4bd0
...
...
@@ -93,6 +93,35 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
it
(
'should succeed in updating when values are unchanged (without timestamps)'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
DataTypes
.
STRING
,
bio
:
DataTypes
.
TEXT
,
email
:
DataTypes
.
STRING
},
{
timestamps
:
false
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
create
({
name
:
'snafu'
,
email
:
'email'
},
{
fields
:
[
'name'
,
'email'
]
}).
then
(
function
(
user
)
{
return
user
.
update
({
name
:
'snafu'
,
email
:
'email'
});
}).
then
(
function
(
user
)
{
return
user
.
reload
();
}).
then
(
function
(
user
)
{
expect
(
user
.
get
(
'name'
)).
to
.
equal
(
'snafu'
);
expect
(
user
.
get
(
'email'
)).
to
.
equal
(
'email'
);
});
});
});
it
(
'should only save passed attributes'
,
function
()
{
var
user
=
this
.
User
.
build
();
return
user
.
save
().
then
(
function
()
{
...
...
@@ -379,4 +408,4 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
});
});
});
});
\ No newline at end of file
});
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