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 d86c20ed
authored
Sep 07, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue where findOrCreate would not properly release transaction on error, closes #2238
1 parent
c817fd0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
18 deletions
lib/model.js
test/dao-factory/create.test.js
lib/model.js
View file @
d86c20e
...
...
@@ -1141,7 +1141,7 @@ module.exports = (function() {
return
[
instance
,
false
];
});
});
}).
tap
(
function
()
{
}).
finally
(
function
()
{
if
(
internalTransaction
)
{
// If we created a transaction internally, we should clean it up
return
this
.
transaction
.
commit
();
...
...
test/dao-factory/create.test.js
View file @
d86c20e
...
...
@@ -137,36 +137,28 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
"should release transaction when meeting errors"
,
function
(
done
){
it
(
"should release transaction when meeting errors"
,
function
(){
var
self
=
this
var
test
=
function
(
times
)
{
times
=
times
||
0
if
(
times
>
10
)
{
return
true
// stop trying
return
true
;
}
/*without name, trigger ValidationError */
return
self
.
Student
.
findOrCreate
({
where
:{
no
:
1
},
defaults
:{}})
return
self
.
Student
.
findOrCreate
({
where
:
{
no
:
1
}
})
.
timeout
(
1000
)
.
catch
(
Promise
.
TimeoutError
,
function
(
e
){
throw
new
Error
(
e
)
})
.
then
(
function
(){
return
true
})
.
catch
(
Sequelize
.
ValidationError
,
function
(
err
){
return
test
(
times
+
1
)
return
test
(
times
+
1
)
;
})
}
test
()
.
then
(
function
(){
done
()
})
.
catch
(
function
(
err
){
done
(
err
)
})
return
test
(
0
);
})
describe
(
'several concurrent calls'
,
function
()
{
...
...
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