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
不要怂,就是干,撸起袖子干!
You need to sign in or sign up before continuing.
Commit d1b370e4
authored
Mar 21, 2015
by
Manuel Martinez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bulkCreate validation with individualHooks returns an array of errors when valid…
…ation fails. Fix #3356
1 parent
34ff44cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
lib/model.js
test/integration/model.test.js
lib/model.js
View file @
d1b370e
...
...
@@ -1351,7 +1351,11 @@ module.exports = (function() {
return
Promise
.
map
(
instances
,
function
(
instance
)
{
// hookValidate rejects with errors, validate returns with errors
if
(
options
.
individualHooks
)
{
return
instance
.
hookValidate
(
options
);
return
instance
.
hookValidate
(
options
).
catch
(
function
(
err
)
{
if
(
err
)
{
errors
.
push
({
record
:
instance
,
errors
:
err
});
}
});
}
else
{
return
instance
.
validate
(
options
).
then
(
function
(
err
)
{
if
(
err
)
{
...
...
test/integration/model.test.js
View file @
d1b370e
...
...
@@ -2561,3 +2561,30 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return
this
.
sequelize
.
sync
({
force
:
true
});
});
});
it
(
'should return array of errors if validate and individualHooks are true in bulkCreate'
,
function
()
{
var
self
=
this
,
data
=
[{
username
:
null
},
{
username
:
null
},
{
username
:
null
}];
var
user
=
this
.
sequelize
.
define
(
'Users'
,
{
username
:
{
type
:
Sequelize
.
STRING
,
allowNull
:
false
,
validate
:
{
notNull
:
true
,
notEmpty
:
true
}
}
});
user
.
bulkCreate
(
data
,
{
validate
:
true
,
individualHooks
:
true
})
.
catch
(
function
(
errors
)
{
expect
(
errors
).
to
.
be
.
instanceof
(
Array
);
});
});
\ No newline at end of file
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