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 e2dad2f9
authored
Oct 10, 2017
by
Tyler Watson
Committed by
Sushant
Oct 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(transactions): don't use CLS on manually manged transactions (#8430)
1 parent
e695b92c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
3 deletions
lib/sequelize.js
lib/transaction.js
test/integration/cls.test.js
lib/sequelize.js
View file @
e2dad2f
...
@@ -962,7 +962,7 @@ class Sequelize {
...
@@ -962,7 +962,7 @@ class Sequelize {
const
transaction
=
new
Transaction
(
this
,
options
);
const
transaction
=
new
Transaction
(
this
,
options
);
if
(
!
autoCallback
)
return
transaction
.
prepareEnvironment
().
return
(
transaction
);
if
(
!
autoCallback
)
return
transaction
.
prepareEnvironment
(
false
).
return
(
transaction
);
// autoCallback provided
// autoCallback provided
return
Sequelize
.
_clsRun
(()
=>
{
return
Sequelize
.
_clsRun
(()
=>
{
...
...
lib/transaction.js
View file @
e2dad2f
...
@@ -99,9 +99,13 @@ class Transaction {
...
@@ -99,9 +99,13 @@ class Transaction {
});
});
}
}
prepareEnvironment
()
{
prepareEnvironment
(
useCLS
)
{
let
connectionPromise
;
let
connectionPromise
;
if
(
typeof
useCLS
===
'undefined'
)
{
useCLS
=
true
;
}
if
(
this
.
parent
)
{
if
(
this
.
parent
)
{
connectionPromise
=
Utils
.
Promise
.
resolve
(
this
.
parent
.
connection
);
connectionPromise
=
Utils
.
Promise
.
resolve
(
this
.
parent
.
connection
);
}
else
{
}
else
{
...
@@ -125,7 +129,7 @@ class Transaction {
...
@@ -125,7 +129,7 @@ class Transaction {
throw
setupErr
;
throw
setupErr
;
}))
}))
.
tap
(()
=>
{
.
tap
(()
=>
{
if
(
this
.
sequelize
.
constructor
.
_cls
)
{
if
(
useCLS
&&
this
.
sequelize
.
constructor
.
_cls
)
{
this
.
sequelize
.
constructor
.
_cls
.
set
(
'transaction'
,
this
);
this
.
sequelize
.
constructor
.
_cls
.
set
(
'transaction'
,
this
);
}
}
return
null
;
return
null
;
...
...
test/integration/cls.test.js
View file @
e2dad2f
...
@@ -33,6 +33,17 @@ if (current.dialect.supports.transactions) {
...
@@ -33,6 +33,17 @@ if (current.dialect.supports.transactions) {
});
});
describe
(
'context'
,
()
=>
{
describe
(
'context'
,
()
=>
{
it
(
'does not use continuation storage on manually managed transactions'
,
function
()
{
const
self
=
this
;
return
Sequelize
.
_clsRun
(()
=>
{
return
this
.
sequelize
.
transaction
().
then
(
transaction
=>
{
expect
(
self
.
ns
.
get
(
'transaction'
)).
to
.
be
.
undefined
;
return
transaction
.
rollback
();
});
});
});
it
(
'supports several concurrent transactions'
,
function
()
{
it
(
'supports several concurrent transactions'
,
function
()
{
let
t1id
,
t2id
;
let
t1id
,
t2id
;
const
self
=
this
;
const
self
=
this
;
...
...
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