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 cafa41dd
authored
Mar 16, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(delete): cascade getter does not necessarily return array
1 parent
97ef72a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
lib/query-interface.js
test/integration/hooks.test.js
lib/query-interface.js
View file @
cafa41d
...
@@ -631,6 +631,8 @@ module.exports = (function() {
...
@@ -631,6 +631,8 @@ module.exports = (function() {
return
Promise
.
reduce
(
cascades
,
function
(
memo
,
cascade
)
{
return
Promise
.
reduce
(
cascades
,
function
(
memo
,
cascade
)
{
return
dao
[
cascade
]().
then
(
function
(
instances
)
{
return
dao
[
cascade
]().
then
(
function
(
instances
)
{
if
(
!
Array
.
isArray
(
instances
))
instances
=
[
instances
];
return
Promise
.
reduce
(
instances
,
function
(
memo
,
instance
)
{
return
Promise
.
reduce
(
instances
,
function
(
memo
,
instance
)
{
return
instance
.
destroy
();
return
instance
.
destroy
();
},
[]);
},
[]);
...
...
test/integration/hooks.test.js
View file @
cafa41d
...
@@ -4676,12 +4676,13 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -4676,12 +4676,13 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
});
});
});
});
it
(
'with errors'
,
function
(
done
)
{
it
(
'with errors'
,
function
()
{
var
self
=
this
var
self
=
this
,
beforeProject
=
false
,
beforeProject
=
false
,
afterProject
=
false
,
afterProject
=
false
,
beforeTask
=
false
,
beforeTask
=
false
,
afterTask
=
false
;
,
afterTask
=
false
,
VeryCustomError
=
function
()
{};
this
.
Projects
.
beforeCreate
(
function
(
project
,
options
,
fn
)
{
this
.
Projects
.
beforeCreate
(
function
(
project
,
options
,
fn
)
{
beforeProject
=
true
;
beforeProject
=
true
;
...
@@ -4695,7 +4696,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -4695,7 +4696,7 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
this
.
Tasks
.
beforeDestroy
(
function
(
task
,
options
,
fn
)
{
this
.
Tasks
.
beforeDestroy
(
function
(
task
,
options
,
fn
)
{
beforeTask
=
true
;
beforeTask
=
true
;
fn
(
new
Error
(
'Whoops!'
));
fn
(
new
VeryCustom
Error
(
'Whoops!'
));
});
});
this
.
Tasks
.
afterDestroy
(
function
(
task
,
options
,
fn
)
{
this
.
Tasks
.
afterDestroy
(
function
(
task
,
options
,
fn
)
{
...
@@ -4703,16 +4704,14 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
...
@@ -4703,16 +4704,14 @@ describe(Support.getTestDialectTeaser('Hooks'), function() {
fn
();
fn
();
});
});
this
.
Projects
.
create
({
title
:
'New Project'
}).
success
(
function
(
project
)
{
return
this
.
Projects
.
create
({
title
:
'New Project'
}).
then
(
function
(
project
)
{
self
.
Tasks
.
create
({
title
:
'New Task'
}).
success
(
function
(
task
)
{
return
self
.
Tasks
.
create
({
title
:
'New Task'
}).
then
(
function
(
task
)
{
project
.
setTask
(
task
).
success
(
function
()
{
return
project
.
setTask
(
task
).
then
(
function
()
{
project
.
destroy
().
error
(
function
(
err
)
{
return
expect
(
project
.
destroy
()).
to
.
eventually
.
be
.
rejectedWith
(
VeryCustomError
).
then
(
function
()
{
expect
(
err
).
to
.
be
.
instanceOf
(
Error
);
expect
(
beforeProject
).
to
.
be
.
true
;
expect
(
beforeProject
).
to
.
be
.
true
;
expect
(
afterProject
).
to
.
be
.
true
;
expect
(
afterProject
).
to
.
be
.
true
;
expect
(
beforeTask
).
to
.
be
.
true
;
expect
(
beforeTask
).
to
.
be
.
true
;
expect
(
afterTask
).
to
.
be
.
false
;
expect
(
afterTask
).
to
.
be
.
false
;
done
();
});
});
});
});
});
});
...
...
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