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 729575e0
authored
Feb 04, 2017
by
Maks Nemisj
Committed by
Sushant
Feb 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master:fix-previous-value (#7189)
1 parent
0c2f20b4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletions
changelog.md
lib/model.js
test/unit/instance/previous.test.js
changelog.md
View file @
729575e
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
-
[
FIXED
]
scope method syntax loses parameters when used multiple times
[
#7058
](
https://github.com/sequelize/sequelize/issues/7058
)
-
[
FIXED
]
scope method syntax loses parameters when used multiple times
[
#7058
](
https://github.com/sequelize/sequelize/issues/7058
)
-
[
INTERNAL
]
Updated to
`generic-pool@3.1.6`
[
#7109
](
https://github.com/sequelize/sequelize/issues/7109
)
-
[
INTERNAL
]
Updated to
`generic-pool@3.1.6`
[
#7109
](
https://github.com/sequelize/sequelize/issues/7109
)
-
[
FIXED
]
findAll throws error if attributes option is formatted incorrectly
[
#7162
](
https://github.com/sequelize/sequelize/issues/7163
)
-
[
FIXED
]
findAll throws error if attributes option is formatted incorrectly
[
#7162
](
https://github.com/sequelize/sequelize/issues/7163
)
-
[
FIXED
]
previous gave wrong value back
[
#7189
](
https://github.com/sequelize/sequelize/pull/7189
)
## BC breaks:
## BC breaks:
-
`DATEONLY`
now returns string in
`YYYY-MM-DD`
format rather than
`Date`
type
-
`DATEONLY`
now returns string in
`YYYY-MM-DD`
format rather than
`Date`
type
...
...
lib/model.js
View file @
729575e
...
@@ -2977,11 +2977,12 @@ class Model {
...
@@ -2977,11 +2977,12 @@ class Model {
* @param {any} value
* @param {any} value
*/
*/
setDataValue
(
key
,
value
)
{
setDataValue
(
key
,
value
)
{
const
originalValue
=
this
.
_previousD
ataValues
[
key
];
const
originalValue
=
this
.
d
ataValues
[
key
];
if
(
!
Utils
.
isPrimitive
(
value
)
||
value
!==
originalValue
)
{
if
(
!
Utils
.
isPrimitive
(
value
)
||
value
!==
originalValue
)
{
this
.
changed
(
key
,
true
);
this
.
changed
(
key
,
true
);
}
}
this
.
_previousDataValues
[
key
]
=
originalValue
;
this
.
dataValues
[
key
]
=
value
;
this
.
dataValues
[
key
]
=
value
;
}
}
...
...
test/unit/instance/previous.test.js
0 → 100644
View file @
729575e
'use strict'
;
/* jshint -W030 */
var
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../support'
)
,
DataTypes
=
require
(
__dirname
+
'/../../../lib/data-types'
)
,
current
=
Support
.
sequelize
;
describe
(
Support
.
getTestDialectTeaser
(
'Instance'
),
function
()
{
describe
(
'previous'
,
function
()
{
it
(
'should return correct previous value'
,
function
()
{
var
Model
=
current
.
define
(
'Model'
,
{
text
:
{
type
:
DataTypes
.
STRING
,
get
:
function
(
name
)
{
return
this
.
getDataValue
(
name
);
},
set
:
function
(
value
,
name
)
{
this
.
setDataValue
(
name
,
value
);
}
}
})
,
instance
,
shouldBeEmpty
,
shouldBeA
;
instance
=
Model
.
build
({
text
:
'a'
},
{
isNewRecord
:
false
});
shouldBeEmpty
=
instance
.
previous
(
'text'
);
instance
.
set
(
'text'
,
'b'
);
shouldBeA
=
instance
.
previous
(
'text'
);
expect
(
shouldBeEmpty
).
to
.
be
.
not
.
ok
;
expect
(
shouldBeA
).
to
.
be
.
equal
(
'a'
);
});
});
});
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