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 c9e23615
authored
Sep 07, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ryanking8215-test/issue_2238'
2 parents
6fccaa8d
d86c20ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
lib/model.js
test/dao-factory/create.test.js
lib/model.js
View file @
c9e2361
...
@@ -1141,7 +1141,7 @@ module.exports = (function() {
...
@@ -1141,7 +1141,7 @@ module.exports = (function() {
return
[
instance
,
false
];
return
[
instance
,
false
];
});
});
});
});
}).
tap
(
function
()
{
}).
finally
(
function
()
{
if
(
internalTransaction
)
{
if
(
internalTransaction
)
{
// If we created a transaction internally, we should clean it up
// If we created a transaction internally, we should clean it up
return
this
.
transaction
.
commit
();
return
this
.
transaction
.
commit
();
...
...
test/dao-factory/create.test.js
View file @
c9e2361
...
@@ -31,6 +31,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -31,6 +31,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this
.
Account
=
this
.
sequelize
.
define
(
'Account'
,
{
this
.
Account
=
this
.
sequelize
.
define
(
'Account'
,
{
accountName
:
DataTypes
.
STRING
accountName
:
DataTypes
.
STRING
});
});
this
.
Student
=
this
.
sequelize
.
define
(
'Student'
,
{
no
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
},
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
})
return
this
.
sequelize
.
sync
({
force
:
true
});
return
this
.
sequelize
.
sync
({
force
:
true
});
});
});
...
@@ -133,6 +137,30 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -133,6 +137,30 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
(
"should release transaction when meeting errors"
,
function
(){
var
self
=
this
var
test
=
function
(
times
)
{
if
(
times
>
10
)
{
return
true
;
}
return
self
.
Student
.
findOrCreate
({
where
:
{
no
:
1
}
})
.
timeout
(
1000
)
.
catch
(
Promise
.
TimeoutError
,
function
(
e
){
throw
new
Error
(
e
)
})
.
catch
(
Sequelize
.
ValidationError
,
function
(
err
){
return
test
(
times
+
1
);
})
}
return
test
(
0
);
})
describe
(
'several concurrent calls'
,
function
()
{
describe
(
'several concurrent calls'
,
function
()
{
it
(
'works with a transaction'
,
function
()
{
it
(
'works with a transaction'
,
function
()
{
return
this
.
sequelize
.
transaction
().
bind
(
this
).
then
(
function
(
transaction
)
{
return
this
.
sequelize
.
transaction
().
bind
(
this
).
then
(
function
(
transaction
)
{
...
...
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