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 71587641
authored
Dec 21, 2015
by
Sushant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix(#4702): Instance returns this on all paths
1 parent
36794378
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
changelog.md
lib/instance.js
changelog.md
View file @
7158764
# Future
# Future
-
[
FIXED
]
calling Model.update() modifies passed values
[
#4520
](
https://github.com/sequelize/sequelize/issues/4520
)
-
[
FIXED
]
calling Model.update() modifies passed values
[
#4520
](
https://github.com/sequelize/sequelize/issues/4520
)
-
[
FIXED
]
Instance can be chained on .set() and other methods
[
#4702
](
https://github.com/sequelize/sequelize/issues/4702
)
# 3.15.0
# 3.15.0
-
[
ADDED
]
Improve support for pg range type to handle unbound ranges, +/-infinity bounds and empty ranges
-
[
ADDED
]
Improve support for pg range type to handle unbound ranges, +/-infinity bounds and empty ranges
...
...
lib/instance.js
View file @
7158764
...
@@ -314,7 +314,7 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
...
@@ -314,7 +314,7 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
if
(
this
.
$options
&&
this
.
$options
.
include
&&
this
.
$options
.
includeNames
.
indexOf
(
key
)
!==
-
1
)
{
if
(
this
.
$options
&&
this
.
$options
.
include
&&
this
.
$options
.
includeNames
.
indexOf
(
key
)
!==
-
1
)
{
// Pass it on to the include handler
// Pass it on to the include handler
this
.
_setInclude
(
key
,
value
,
options
);
this
.
_setInclude
(
key
,
value
,
options
);
return
;
return
this
;
}
else
{
}
else
{
// Bunch of stuff we won't do when its raw
// Bunch of stuff we won't do when its raw
if
(
!
options
.
raw
)
{
if
(
!
options
.
raw
)
{
...
@@ -327,17 +327,17 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
...
@@ -327,17 +327,17 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
this
.
changed
(
key
.
split
(
'.'
)[
0
],
true
);
this
.
changed
(
key
.
split
(
'.'
)[
0
],
true
);
}
}
}
}
return
;
return
this
;
}
}
// If attempting to set primary key and primary key is already defined, return
// If attempting to set primary key and primary key is already defined, return
if
(
this
.
Model
.
_hasPrimaryKeys
&&
originalValue
&&
this
.
Model
.
_isPrimaryKey
(
key
))
{
if
(
this
.
Model
.
_hasPrimaryKeys
&&
originalValue
&&
this
.
Model
.
_isPrimaryKey
(
key
))
{
return
;
return
this
;
}
}
// If attempting to set read only attributes, return
// If attempting to set read only attributes, return
if
(
!
this
.
isNewRecord
&&
this
.
Model
.
_hasReadOnlyAttributes
&&
this
.
Model
.
_isReadOnlyAttribute
(
key
))
{
if
(
!
this
.
isNewRecord
&&
this
.
Model
.
_hasReadOnlyAttributes
&&
this
.
Model
.
_isReadOnlyAttribute
(
key
))
{
return
;
return
this
;
}
}
// Convert date fields to real date objects
// Convert date fields to real date objects
...
@@ -349,7 +349,7 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
...
@@ -349,7 +349,7 @@ Instance.prototype.set = function(key, value, options) { // testhint options:non
originalValue
=
new
Date
(
originalValue
);
originalValue
=
new
Date
(
originalValue
);
}
}
if
(
originalValue
&&
value
.
getTime
()
===
originalValue
.
getTime
())
{
if
(
originalValue
&&
value
.
getTime
()
===
originalValue
.
getTime
())
{
return
;
return
this
;
}
}
}
}
}
}
...
@@ -693,8 +693,8 @@ Instance.prototype.save = function(options) {
...
@@ -693,8 +693,8 @@ Instance.prototype.save = function(options) {
return
result
;
return
result
;
})
})
.
tap
(
function
()
{
.
tap
(
function
()
{
if
(
!
wasNewRecord
)
return
;
if
(
!
wasNewRecord
)
return
self
;
if
(
!
self
.
$options
.
include
||
!
self
.
$options
.
include
.
length
)
return
;
if
(
!
self
.
$options
.
include
||
!
self
.
$options
.
include
.
length
)
return
self
;
// Nested creation for HasOne/HasMany/BelongsToMany relations
// Nested creation for HasOne/HasMany/BelongsToMany relations
return
Promise
.
map
(
self
.
$options
.
include
.
filter
(
function
(
include
)
{
return
Promise
.
map
(
self
.
$options
.
include
.
filter
(
function
(
include
)
{
...
...
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