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 1497e0dc
authored
Jan 27, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement changes needed for #2380
1 parent
c96e376f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
lib/dialects/sqlite/connection-manager.js
lib/sequelize.js
test/integration/transaction.test.js
lib/dialects/sqlite/connection-manager.js
View file @
1497e0d
...
...
@@ -11,6 +11,9 @@ ConnectionManager = function(dialect, sequelize) {
this
.
dialect
=
dialect
;
this
.
connections
=
{};
// We attempt to parse file location from a connection uri but we shouldn't match sequelize default host.
if
(
this
.
sequelize
.
options
.
host
===
'localhost'
)
delete
this
.
sequelize
.
options
.
host
;
try
{
this
.
lib
=
require
(
sequelize
.
config
.
dialectModulePath
||
'sqlite3'
).
verbose
();
}
catch
(
err
)
{
...
...
@@ -24,7 +27,7 @@ ConnectionManager.prototype.getConnection = function(options) {
var
self
=
this
;
options
=
options
||
{};
options
.
uuid
=
options
.
uuid
||
'default'
;
options
.
inMemory
=
((
self
.
sequelize
.
options
.
storage
||
':memory:'
)
===
':memory:'
)?
1
:
0
;
options
.
inMemory
=
((
self
.
sequelize
.
options
.
storage
||
self
.
sequelize
.
options
.
host
||
':memory:'
)
===
':memory:'
)
?
1
:
0
;
if
(
self
.
connections
[
options
.
inMemory
||
options
.
uuid
])
return
Promise
.
resolve
(
self
.
connections
[
options
.
inMemory
||
options
.
uuid
]);
...
...
@@ -45,9 +48,12 @@ ConnectionManager.prototype.getConnection = function(options) {
});
};
ConnectionManager
.
prototype
.
releaseConnection
=
function
(
connection
)
{
ConnectionManager
.
prototype
.
releaseConnection
=
function
(
connection
,
force
)
{
if
(
connection
.
filename
===
":memory:"
&&
force
!==
true
)
return
;
if
(
connection
.
uuid
)
{
connection
.
close
();
delete
this
.
connections
[
connection
.
uuid
];
}
};
...
...
lib/sequelize.js
View file @
1497e0d
...
...
@@ -676,7 +676,7 @@ module.exports = (function() {
).
then
(
function
(
connection
)
{
var
query
=
new
self
.
dialect
.
Query
(
connection
,
self
,
callee
,
options
);
return
query
.
run
(
sql
).
finally
(
function
()
{
if
(
options
.
transaction
||
(
connection
.
filename
===
":memory:"
)
)
return
;
if
(
options
.
transaction
)
return
;
return
self
.
connectionManager
.
releaseConnection
(
connection
);
});
});
...
...
test/integration/transaction.test.js
View file @
1497e0d
...
...
@@ -87,12 +87,13 @@ describe(Support.getTestDialectTeaser('Transaction'), function() {
});
if
(
dialect
===
'sqlite'
){
it
(
'provides persistent transactions'
,
function
(
done
)
{
it
(
'provides persistent transactions'
,
function
()
{
var
sequelize
=
new
Support
.
Sequelize
(
'database'
,
'username'
,
'password'
,
{
dialect
:
'sqlite'
}),
User
=
sequelize
.
define
(
'user'
,
{
username
:
Support
.
Sequelize
.
STRING
,
awesome
:
Support
.
Sequelize
.
BOOLEAN
});
return
sequelize
.
transaction
()
.
then
(
function
(
t
)
{
return
sequelize
.
sync
({
transaction
:
t
})
...
...
@@ -114,9 +115,6 @@ describe(Support.getTestDialectTeaser('Transaction'), function() {
})
.
then
(
function
(
users
)
{
return
expect
(
users
.
length
).
to
.
equal
(
1
);
})
.
then
(
function
(
object
)
{
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