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 8b0b03c8
authored
Apr 05, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont validate fields that are not saved. Closes #1449
1 parent
8536013f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
lib/dao.js
test/dao.test.js
lib/dao.js
View file @
8b0b03c
...
@@ -305,9 +305,9 @@ module.exports = (function() {
...
@@ -305,9 +305,9 @@ module.exports = (function() {
}
}
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
self
.
hookValidate
(
).
error
(
function
(
err
)
{
self
.
hookValidate
({
return
emitter
.
emit
(
'error'
,
err
)
skip
:
_
.
difference
(
Object
.
keys
(
self
.
rawAttributes
),
options
.
fields
)
}).
success
(
function
()
{
}).
proxy
(
emitter
,
{
events
:
[
'error'
]
}).
success
(
function
()
{
options
.
fields
.
forEach
(
function
(
field
)
{
options
.
fields
.
forEach
(
function
(
field
)
{
if
(
self
.
dataValues
[
field
]
!==
undefined
)
{
if
(
self
.
dataValues
[
field
]
!==
undefined
)
{
values
[
field
]
=
self
.
dataValues
[
field
]
values
[
field
]
=
self
.
dataValues
[
field
]
...
...
test/dao.test.js
View file @
8b0b03c
...
@@ -780,6 +780,15 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
...
@@ -780,6 +780,15 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
})
})
it
(
'only validates fields in passed array'
,
function
(
done
)
{
this
.
User
.
build
({
validateTest
:
'cake'
,
// invalid, but not saved
validateCustom
:
'1'
}).
save
([
'validateCustom'
]).
success
(
function
()
{
done
()
})
})
it
(
"stores an entry in the database"
,
function
(
done
)
{
it
(
"stores an entry in the database"
,
function
(
done
)
{
var
username
=
'user'
var
username
=
'user'
,
User
=
this
.
User
,
User
=
this
.
User
...
...
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