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 edd72bb7
authored
Jul 15, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:sdepold/sequelize
2 parents
1f438123
d559bcfb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
lib/dialects/postgres/connector-manager.js
spec-jasmine/config/config.js
lib/dialects/postgres/connector-manager.js
View file @
edd72bb
var
Query
=
require
(
"./query"
)
var
Query
=
require
(
"./query"
)
,
Utils
=
require
(
"../../utils"
)
,
Utils
=
require
(
"../../utils"
)
,
pg
=
require
(
"pg"
)
,
without
=
function
(
arr
,
elem
)
{
return
arr
.
filter
(
function
(
e
)
{
return
e
!=
elem
})
}
,
without
=
function
(
arr
,
elem
)
{
return
arr
.
filter
(
function
(
e
)
{
return
e
!=
elem
})
}
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
...
@@ -7,6 +8,12 @@ module.exports = (function() {
...
@@ -7,6 +8,12 @@ module.exports = (function() {
this
.
sequelize
=
sequelize
this
.
sequelize
=
sequelize
this
.
client
=
null
this
.
client
=
null
this
.
config
=
config
||
{}
this
.
config
=
config
||
{}
this
.
pooling
=
(
this
.
config
.
poolCfg
!=
null
&&
this
.
config
.
poolCfg
.
maxConnections
>
0
)
// set pooling parameters if specified
if
(
this
.
pooling
)
{
pg
.
defaults
.
poolSize
=
this
.
config
.
poolCfg
.
maxConnections
pg
.
defaults
.
poolIdleTimeout
=
this
.
config
.
poolCfg
.
maxIdleTime
}
this
.
disconnectTimeoutId
=
null
this
.
disconnectTimeoutId
=
null
this
.
pendingQueries
=
0
this
.
pendingQueries
=
0
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
...
@@ -44,12 +51,9 @@ module.exports = (function() {
...
@@ -44,12 +51,9 @@ module.exports = (function() {
this
.
isConnecting
=
true
this
.
isConnecting
=
true
this
.
isConnected
=
false
this
.
isConnected
=
false
var
pg
=
require
(
"pg"
)
var
uri
=
this
.
sequelize
.
getQueryInterface
().
QueryGenerator
.
databaseConnectionUri
(
this
.
config
)
,
uri
=
this
.
sequelize
.
getQueryInterface
().
QueryGenerator
.
databaseConnectionUri
(
this
.
config
)
this
.
client
=
new
pg
.
Client
(
uri
)
this
.
client
.
connect
(
function
(
err
,
client
)
{
var
connectCallback
=
function
(
err
,
client
)
{
self
.
isConnecting
=
false
self
.
isConnecting
=
false
if
(
!
err
&&
client
)
{
if
(
!
err
&&
client
)
{
client
.
query
(
"SET TIME ZONE 'UTC'"
)
client
.
query
(
"SET TIME ZONE 'UTC'"
)
...
@@ -60,7 +64,17 @@ module.exports = (function() {
...
@@ -60,7 +64,17 @@ module.exports = (function() {
}
else
{
}
else
{
this
.
client
=
null
this
.
client
=
null
}
}
})
}
if
(
this
.
pooling
)
{
// acquire client from pool
pg
.
connect
(
uri
,
connectCallback
)
}
else
{
//create one-off client
this
.
client
=
new
pg
.
Client
(
uri
)
this
.
client
.
connect
(
connectCallback
)
}
}
}
ConnectorManager
.
prototype
.
disconnect
=
function
()
{
ConnectorManager
.
prototype
.
disconnect
=
function
()
{
...
...
spec-jasmine/config/config.js
View file @
edd72bb
...
@@ -19,7 +19,8 @@ module.exports = {
...
@@ -19,7 +19,8 @@ module.exports = {
postgres
:
{
postgres
:
{
database
:
'sequelize_test'
,
database
:
'sequelize_test'
,
username
:
"postgres"
,
username
:
"postgres"
,
port
:
5432
port
:
5432
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
}
}
}
}
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