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 7fdc2dcb
authored
May 18, 2020
by
Tony Brix
Committed by
GitHub
May 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mssql): tedious connect deprecation (#12275)
1 parent
8a3827d0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
lib/dialects/mssql/connection-manager.js
test/unit/dialects/mssql/connection-manager.test.js
lib/dialects/mssql/connection-manager.js
View file @
7fdc2dc
...
@@ -61,6 +61,9 @@ class ConnectionManager extends AbstractConnectionManager {
...
@@ -61,6 +61,9 @@ class ConnectionManager extends AbstractConnectionManager {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
connection
=
new
this
.
lib
.
Connection
(
connectionConfig
);
const
connection
=
new
this
.
lib
.
Connection
(
connectionConfig
);
if
(
connection
.
state
===
connection
.
STATE
.
INITIALIZED
)
{
connection
.
connect
();
}
connection
.
lib
=
this
.
lib
;
connection
.
lib
=
this
.
lib
;
const
resourceLock
=
new
ResourceLock
(
connection
);
const
resourceLock
=
new
ResourceLock
(
connection
);
...
...
test/unit/dialects/mssql/connection-manager.test.js
View file @
7fdc2dc
...
@@ -39,6 +39,8 @@ if (dialect === 'mssql') {
...
@@ -39,6 +39,8 @@ if (dialect === 'mssql') {
it
(
'connectionManager._connect() does not delete `domain` from config.dialectOptions'
,
function
()
{
it
(
'connectionManager._connect() does not delete `domain` from config.dialectOptions'
,
function
()
{
this
.
connectionStub
.
returns
({
this
.
connectionStub
.
returns
({
STATE
:
{},
state
:
''
,
once
(
event
,
cb
)
{
once
(
event
,
cb
)
{
if
(
event
===
'connect'
)
{
if
(
event
===
'connect'
)
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -58,6 +60,8 @@ if (dialect === 'mssql') {
...
@@ -58,6 +60,8 @@ if (dialect === 'mssql') {
it
(
'connectionManager._connect() should reject if end was called and connect was not'
,
function
()
{
it
(
'connectionManager._connect() should reject if end was called and connect was not'
,
function
()
{
this
.
connectionStub
.
returns
({
this
.
connectionStub
.
returns
({
STATE
:
{},
state
:
''
,
once
(
event
,
cb
)
{
once
(
event
,
cb
)
{
if
(
event
===
'end'
)
{
if
(
event
===
'end'
)
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -75,5 +79,29 @@ if (dialect === 'mssql') {
...
@@ -75,5 +79,29 @@ if (dialect === 'mssql') {
expect
(
err
.
parent
.
message
).
to
.
equal
(
'Connection was closed by remote server'
);
expect
(
err
.
parent
.
message
).
to
.
equal
(
'Connection was closed by remote server'
);
});
});
});
});
it
(
'connectionManager._connect() should call connect if state is initialized'
,
function
()
{
const
connectStub
=
sinon
.
stub
();
const
INITIALIZED
=
{
name
:
'INITIALIZED'
};
this
.
connectionStub
.
returns
({
STATE
:
{
INITIALIZED
},
state
:
INITIALIZED
,
connect
:
connectStub
,
once
(
event
,
cb
)
{
if
(
event
===
'connect'
)
{
setTimeout
(()
=>
{
cb
();
},
500
);
}
},
removeListener
:
()
=>
{},
on
:
()
=>
{}
});
return
this
.
instance
.
dialect
.
connectionManager
.
_connect
(
this
.
config
)
.
then
(()
=>
{
expect
(
connectStub
.
called
).
to
.
equal
(
true
);
});
});
});
});
}
}
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