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 d336d620
authored
Aug 03, 2013
by
Sascha Depold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:sequelize/sequelize
2 parents
ec2d5dd3
e68eb978
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
lib/dialects/postgres/connector-manager.js
lib/dialects/postgres/connector-manager.js
View file @
d336d62
...
...
@@ -46,11 +46,15 @@ module.exports = (function() {
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
var
self
=
this
// we really want pendingQueries to increment as fast as possible...
self
.
pendingQueries
++
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
self
.
connect
()
.
on
(
'error'
,
function
(
err
)
{
// zero-out the previous increment
self
.
pendingQueries
--
self
.
endQuery
.
call
(
self
)
emitter
.
emit
(
'error'
,
err
)
})
.
on
(
'success'
,
function
(
done
)
{
...
...
@@ -58,14 +62,22 @@ module.exports = (function() {
done
=
done
||
null
query
.
run
(
sql
,
done
)
.
success
(
function
(
results
)
{
emitter
.
emit
(
'success'
,
results
);
self
.
endQuery
.
call
(
self
)
})
.
error
(
function
(
err
)
{
emitter
.
emit
(
'error'
,
err
);
self
.
endQuery
.
call
(
self
)
})
.
success
(
function
(
results
)
{
self
.
pendingQueries
--
emitter
.
emit
(
'success'
,
results
)
self
.
endQuery
.
call
(
self
)
})
.
error
(
function
(
err
)
{
self
.
pendingQueries
--
emitter
.
emit
(
'error'
,
err
)
self
.
endQuery
.
call
(
self
)
})
.
on
(
'sql'
,
function
(
sql
)
{
emitter
.
emit
(
'sql'
,
sql
)
})
})
}).
run
()
.
complete
(
function
()
{
self
.
pendingQueries
--
})
}).
run
()
}
ConnectorManager
.
prototype
.
connect
=
function
(
callback
)
{
ConnectorManager
.
prototype
.
connect
=
function
()
{
var
self
=
this
var
emitter
=
new
(
require
(
'events'
).
EventEmitter
)()
...
...
@@ -119,9 +131,13 @@ module.exports = (function() {
this
.
poolIdentifier
=
this
.
pg
.
pools
.
getOrCreate
(
this
.
sequelize
.
config
)
this
.
poolIdentifier
.
connect
(
connectCallback
)
}
else
{
//create one-off client
this
.
client
=
new
this
.
pg
.
Client
(
uri
)
this
.
client
.
connect
(
connectCallback
)
if
(
this
.
client
!==
null
)
{
connectCallback
(
null
,
this
.
client
)
}
else
{
//create one-off client
this
.
client
=
new
this
.
pg
.
Client
(
uri
)
this
.
client
.
connect
(
connectCallback
)
}
}
return
emitter
...
...
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