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 5a8a6800
authored
Nov 15, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transaction test for bulkDelete
1 parent
20563ff0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
33 deletions
lib/dao-factory.js
lib/query-interface.js
test/dao-factory.test.js
test/dao.test.js
lib/dao-factory.js
View file @
5a8a680
...
...
@@ -685,7 +685,6 @@ module.exports = (function() {
}
daos
[
i
]
=
newValues
||
daos
[
i
]
console
.
log
(
'....................'
)
daos
[
i
].
save
({
transaction
:
options
.
transaction
}).
error
(
function
(
err
)
{
emitter
.
emit
(
'error'
,
err
)
}).
success
(
function
()
{
...
...
lib/query-interface.js
View file @
5a8a680
...
...
@@ -617,7 +617,7 @@ module.exports = (function() {
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
()
chainer
.
add
(
self
,
'queryAndEmit'
,
[
sql
,
'bulkDelete'
,
options
])
chainer
.
add
(
self
,
'queryAndEmit'
,
[
[
sql
,
null
,
options
]
,
'bulkDelete'
,
options
])
chainer
.
runSerially
()
.
success
(
function
(
results
){
...
...
test/dao-factory.test.js
View file @
5a8a680
...
...
@@ -1398,41 +1398,22 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
describe
(
'destroy'
,
function
()
{
it
(
'deletes a record from the database if dao is not paranoid'
,
function
(
done
)
{
var
UserDestroy
=
this
.
sequelize
.
define
(
'UserDestroy'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
it
(
'supports transactions'
,
function
(
done
)
{
Support
.
prepareTransactionTest
(
dialect
,
this
.
sequelize
,
function
(
sequelize
)
{
var
User
=
sequelize
.
define
(
'User'
,
{
username
:
Sequelize
.
STRING
})
UserDestroy
.
sync
({
force
:
true
}).
success
(
function
()
{
UserDestroy
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
success
(
function
(
u
)
{
UserDestroy
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
1
)
u
.
destroy
().
success
(
function
()
{
UserDestroy
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
0
)
done
()
})
})
})
})
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
username
:
'foo'
}).
success
(
function
()
{
sequelize
.
transaction
(
function
(
t
)
{
User
.
destroy
({},
{
transaction
:
t
}).
success
(
function
()
{
User
.
count
().
success
(
function
(
count1
)
{
User
.
count
({
transaction
:
t
}).
success
(
function
(
count2
)
{
expect
(
count1
).
to
.
equal
(
1
)
expect
(
count2
).
to
.
equal
(
0
)
t
.
rollback
().
success
(
done
)
})
})
it
(
'allows sql logging of delete statements'
,
function
(
done
)
{
var
UserDelete
=
this
.
sequelize
.
define
(
'UserDelete'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
UserDelete
.
sync
({
force
:
true
}).
success
(
function
()
{
UserDelete
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
success
(
function
(
u
)
{
UserDelete
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
1
)
u
.
destroy
().
on
(
'sql'
,
function
(
sql
)
{
expect
(
sql
).
to
.
exist
expect
(
sql
.
toUpperCase
().
indexOf
(
"DELETE"
)).
to
.
be
.
above
(
-
1
)
done
()
})
})
})
...
...
test/dao.test.js
View file @
5a8a680
...
...
@@ -1275,4 +1275,47 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
})
describe
(
'destroy'
,
function
()
{
it
(
'deletes a record from the database if dao is not paranoid'
,
function
(
done
)
{
var
UserDestroy
=
this
.
sequelize
.
define
(
'UserDestroy'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
UserDestroy
.
sync
({
force
:
true
}).
success
(
function
()
{
UserDestroy
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
success
(
function
(
u
)
{
UserDestroy
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
1
)
u
.
destroy
().
success
(
function
()
{
UserDestroy
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
0
)
done
()
})
})
})
})
})
})
it
(
'allows sql logging of delete statements'
,
function
(
done
)
{
var
UserDelete
=
this
.
sequelize
.
define
(
'UserDelete'
,
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
UserDelete
.
sync
({
force
:
true
}).
success
(
function
()
{
UserDelete
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
success
(
function
(
u
)
{
UserDelete
.
all
().
success
(
function
(
users
)
{
expect
(
users
.
length
).
to
.
equal
(
1
)
u
.
destroy
().
on
(
'sql'
,
function
(
sql
)
{
expect
(
sql
).
to
.
exist
expect
(
sql
.
toUpperCase
().
indexOf
(
"DELETE"
)).
to
.
be
.
above
(
-
1
)
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