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 436cd12e
authored
Dec 04, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4967 from sorin/master
Failing .set test
2 parents
feeff9ef
8727c817
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
lib/utils.js
test/unit/instance/set.test.js
lib/utils.js
View file @
436cd12
...
...
@@ -232,6 +232,8 @@ var Utils = module.exports = {
return
uuid
.
v4
();
}
else
if
(
value
instanceof
DataTypes
.
NOW
)
{
return
Utils
.
now
();
}
else
if
(
_
.
isPlainObject
(
value
)
||
_
.
isArray
(
value
))
{
return
_
.
clone
(
value
);
}
else
{
return
value
;
}
...
...
test/unit/instance/set.test.js
View file @
436cd12
...
...
@@ -28,6 +28,21 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
expect
(
user
.
dataValues
[
'meta.location'
]).
not
.
to
.
be
.
ok
;
expect
(
user
.
get
(
'meta'
).
location
).
to
.
equal
(
'Copenhagen'
);
expect
(
user
.
get
(
'meta'
)
===
meta
).
to
.
equal
(
true
);
expect
(
user
.
get
(
'meta'
)
===
meta
).
to
.
equal
(
true
);
});
it
(
'doesnt mutate the JSONB defaultValue'
,
function
()
{
var
User
=
current
.
define
(
'User'
,
{
meta
:
{
type
:
DataTypes
.
JSONB
,
allowNull
:
false
,
defaultValue
:
{}
}
});
var
user1
=
User
.
build
({});
user1
.
set
(
'meta.location'
,
'Stockhollm'
);
var
user2
=
User
.
build
({});
expect
(
user2
.
get
(
'meta'
)).
to
.
deep
.
equal
({});
});
});
});
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