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 941b36b2
authored
May 15, 2015
by
Ben Stephenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new test for persisting side effects within model.update
1 parent
3dd94d84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
test/integration/model.test.js
test/integration/model.test.js
View file @
941b36b
...
...
@@ -975,6 +975,77 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it
(
'doesn\'t update attributes that are altered by virtual setters when option is enabled'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'UserWithVirtualSetters'
,
{
username
:
Sequelize
.
STRING
,
illness_name
:
Sequelize
.
STRING
,
illness_pain
:
Sequelize
.
INTEGER
,
illness
:
{
type
:
Sequelize
.
VIRTUAL
,
set
:
function
(
value
)
{
this
.
set
(
'illness_name'
,
value
.
name
);
this
.
set
(
'illness_pain'
,
value
.
pain
);
}
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
create
({
username
:
'Jan'
,
illness_name
:
'Headache'
,
illness_pain
:
5
});
}).
then
(
function
()
{
return
User
.
update
({
illness
:
{
pain
:
10
,
name
:
'Backache'
}
},
{
where
:
{
username
:
'Jan'
},
persistSideEffects
:
false
});
}).
then
(
function
(
user
)
{
return
User
.
findAll
();
}).
spread
(
function
(
user
)
{
expect
(
user
.
illness_pain
).
to
.
be
.
equal
(
5
);
});
});
it
(
'updates attributes that are altered by virtual setters'
,
function
()
{
var
User
=
this
.
sequelize
.
define
(
'UserWithVirtualSetters'
,
{
username
:
Sequelize
.
STRING
,
illness_name
:
Sequelize
.
STRING
,
illness_pain
:
Sequelize
.
INTEGER
,
illness
:
{
type
:
Sequelize
.
VIRTUAL
,
set
:
function
(
value
)
{
this
.
set
(
'illness_name'
,
value
.
name
);
this
.
set
(
'illness_pain'
,
value
.
pain
);
}
}
});
return
User
.
sync
({
force
:
true
}).
then
(
function
()
{
return
User
.
create
({
username
:
'Jan'
,
illness_name
:
'Headache'
,
illness_pain
:
5
});
}).
then
(
function
()
{
return
User
.
update
({
illness
:
{
pain
:
10
,
name
:
'Backache'
}
},
{
where
:
{
username
:
'Jan'
}
});
}).
then
(
function
(
user
)
{
return
User
.
findAll
();
}).
spread
(
function
(
user
)
{
expect
(
user
.
illness_pain
).
to
.
be
.
equal
(
10
);
});
});
it
(
'sets updatedAt to the current timestamp'
,
function
()
{
var
data
=
[{
username
:
'Peter'
,
secretValue
:
'42'
},
{
username
:
'Paul'
,
secretValue
:
'42'
},
...
...
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