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 342e18fb
authored
Aug 28, 2018
by
Sushant
Committed by
GitHub
Aug 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(sqlite): close connection properly and cleanup files (#9851)
1 parent
2d499acc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
lib/dialects/sqlite/connection-manager.js
test/integration/dialects/sqlite/connection-manager.test.js
lib/dialects/sqlite/connection-manager.js
View file @
342e18f
...
@@ -33,6 +33,15 @@ class ConnectionManager extends AbstractConnectionManager {
...
@@ -33,6 +33,15 @@ class ConnectionManager extends AbstractConnectionManager {
this
.
refreshTypeParser
(
dataTypes
);
this
.
refreshTypeParser
(
dataTypes
);
}
}
_onProcessExit
()
{
const
promises
=
Object
.
getOwnPropertyNames
(
this
.
connections
)
.
map
(
connection
=>
Promise
.
fromCallback
(
callback
=>
this
.
connections
[
connection
].
close
(
callback
)));
return
Promise
.
all
(
promises
)
.
then
(()
=>
super
.
_onProcessExit
.
call
(
this
));
}
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
_refreshTypeParser
(
dataType
)
{
_refreshTypeParser
(
dataType
)
{
parserStore
.
refresh
(
dataType
);
parserStore
.
refresh
(
dataType
);
...
...
test/integration/dialects/sqlite/connection-manager.test.js
0 → 100644
View file @
342e18f
'use strict'
;
const
chai
=
require
(
'chai'
);
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
expect
=
chai
.
expect
;
const
Support
=
require
(
__dirname
+
'/../../support'
);
const
dialect
=
Support
.
getTestDialect
();
const
DataTypes
=
require
(
__dirname
+
'/../../../../lib/data-types'
);
const
fileName
=
Math
.
random
()
+
'_test.sqlite'
;
if
(
dialect
===
'sqlite'
)
{
describe
(
'[SQLITE Specific] Connection Manager'
,
()
=>
{
after
(()
=>
{
fs
.
unlinkSync
(
path
.
join
(
__dirname
,
fileName
));
});
it
(
'close connection and remove journal and wal files'
,
function
()
{
const
sequelize
=
Support
.
createSequelizeInstance
({
storage
:
path
.
join
(
__dirname
,
fileName
)
});
const
User
=
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
});
return
User
.
sync
({
force
:
true
})
.
then
(()
=>
sequelize
.
query
(
'PRAGMA journal_mode = WAL'
))
.
then
(()
=>
User
.
create
({
username
:
'user1'
}))
.
then
(()
=>
{
return
sequelize
.
transaction
(
transaction
=>
{
return
User
.
create
({
username
:
'user2'
},
{
transaction
});
});
})
.
then
(()
=>
{
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
fileName
))).
to
.
be
.
true
;
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
`
${
fileName
}
-shm`
)),
'shm file should exists'
).
to
.
be
.
true
;
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
`
${
fileName
}
-wal`
)),
'wal file should exists'
).
to
.
be
.
true
;
return
sequelize
.
close
();
})
.
then
(()
=>
{
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
fileName
))).
to
.
be
.
true
;
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
`
${
fileName
}
-shm`
)),
'shm file exists'
).
to
.
be
.
false
;
expect
(
fs
.
existsSync
(
path
.
join
(
__dirname
,
`
${
fileName
}
-wal`
)),
'wal file exists'
).
to
.
be
.
false
;
return
this
.
sequelize
.
query
(
'PRAGMA journal_mode = DELETE'
);
});
});
});
}
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