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 523fbe8c
authored
Apr 05, 2016
by
Ricardo Lopes
Committed by
Jan Aagaard Meier
Apr 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix defaultValues getting overwritten
1 parent
23787de5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
changelog.md
lib/instance.js
test/unit/instance/build.test.js
changelog.md
View file @
523fbe8
# Future
-
[
FIXED
]
Fix defaultValues getting overwritten on build
# 3.21.0
# 3.21.0
-
[
FIXED
]
Confirmed that values modified in validation hooks are preserved
[
#3534
](
https://github.com/sequelize/sequelize/issues/3534
)
-
[
FIXED
]
Confirmed that values modified in validation hooks are preserved
[
#3534
](
https://github.com/sequelize/sequelize/issues/3534
)
-
[
FIXED
]
Support lower case type names in SQLite
[
#5482
](
https://github.com/sequelize/sequelize/issues/5482
)
-
[
FIXED
]
Support lower case type names in SQLite
[
#5482
](
https://github.com/sequelize/sequelize/issues/5482
)
...
...
lib/instance.js
View file @
523fbe8
...
@@ -22,10 +22,9 @@ var initValues = function(values, options) {
...
@@ -22,10 +22,9 @@ var initValues = function(values, options) {
defaults
=
{};
defaults
=
{};
if
(
this
.
Model
.
_hasDefaultValues
)
{
if
(
this
.
Model
.
_hasDefaultValues
)
{
Utils
.
_
.
each
(
this
.
Model
.
_defaultValues
,
function
(
valueFn
,
key
)
{
defaults
=
_
.
mapValues
(
this
.
Model
.
_defaultValues
,
function
(
valueFn
)
{
if
(
defaults
[
key
]
===
undefined
)
{
var
value
=
valueFn
();
defaults
[
key
]
=
valueFn
();
return
(
value
&&
value
.
_isSequelizeMethod
)
?
value
:
_
.
cloneDeep
(
value
);
}
});
});
}
}
...
...
test/unit/instance/build.test.js
View file @
523fbe8
...
@@ -94,5 +94,21 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
...
@@ -94,5 +94,21 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
expect
(
instance
.
get
(
'number2'
)).
not
.
to
.
be
.
undefined
;
expect
(
instance
.
get
(
'number2'
)).
not
.
to
.
be
.
undefined
;
expect
(
instance
.
get
(
'number2'
)).
to
.
equal
(
2
);
expect
(
instance
.
get
(
'number2'
)).
to
.
equal
(
2
);
});
});
it
(
'should clone the default values'
,
function
()
{
var
Model
=
current
.
define
(
'Model'
,
{
data
:
{
type
:
DataTypes
.
JSONB
,
defaultValue
:
{
foo
:
'bar'
}
}
})
,
instance
;
instance
=
Model
.
build
();
instance
.
data
.
foo
=
'biz'
;
expect
(
instance
.
get
(
'data'
)).
to
.
eql
({
foo
:
'biz'
});
expect
(
Model
.
build
().
get
(
'data'
)).
to
.
eql
({
foo
:
'bar'
});
});
});
});
});
});
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