Comparing version 2.10.0 to 2.11.0
@@ -55,6 +55,3 @@ var crypto = require('crypto'); | ||
} else { | ||
con.startup({ | ||
user: self.user, | ||
database: self.database | ||
}); | ||
con.startup(self.getStartupConf()); | ||
} | ||
@@ -64,6 +61,3 @@ }); | ||
con.on('sslconnect', function() { | ||
con.startup({ | ||
user: self.user, | ||
database: self.database | ||
}); | ||
con.startup(self.getStartupConf()); | ||
}); | ||
@@ -199,2 +193,19 @@ | ||
Client.prototype.getStartupConf = function() { | ||
var params = this.connectionParameters; | ||
var data = { | ||
user : params.user , | ||
database : params.database | ||
// client_encoding : "'".concat(params.client_encoding).concat("'") | ||
}; | ||
var appName = params.application_name || params.fallback_application_name; | ||
if (appName) { | ||
data.application_name = appName; | ||
} | ||
return data; | ||
}; | ||
Client.prototype.cancel = function(client, query) { | ||
@@ -201,0 +212,0 @@ if(client.activeQuery == query) { |
@@ -6,5 +6,13 @@ var dns = require('dns'); | ||
var val = function(key, config) { | ||
var val = function(key, config, envVar) { | ||
if (envVar === undefined) { | ||
envVar = process.env[ 'PG' + key.toUpperCase() ]; | ||
} else if (envVar === false) { | ||
// do nothing ... use false | ||
} else { | ||
envVar = process.env[ envVar ]; | ||
} | ||
return config[key] || | ||
process.env['PG' + key.toUpperCase()] || | ||
envVar || | ||
defaults[key]; | ||
@@ -26,2 +34,10 @@ }; | ||
config = {}; | ||
if (result.query.application_name) { | ||
config.application_name = result.query.application_name; | ||
} | ||
if (result.query.fallback_application_name) { | ||
config.fallback_application_name = result.query.fallback_application_name; | ||
} | ||
if(result.protocol == 'socket:') { | ||
@@ -73,2 +89,5 @@ config.host = decodeURI(result.pathname); | ||
this.isDomainSocket = (!(this.host||'').indexOf('/')); | ||
this.application_name = val('application_name', config, 'PGAPPNAME'); | ||
this.fallback_application_name = val('fallback_application_name', config, false); | ||
}; | ||
@@ -88,2 +107,5 @@ | ||
add(params, this, 'port'); | ||
add(params, this, 'application_name'); | ||
add(params, this, 'fallback_application_name'); | ||
if(this.database) { | ||
@@ -90,0 +112,0 @@ params.push("dbname='" + this.database + "'"); |
@@ -120,12 +120,15 @@ var net = require('net'); | ||
Connection.prototype.startup = function(config) { | ||
var bodyBuffer = this.writer | ||
var writer = this.writer | ||
.addInt16(3) | ||
.addInt16(0) | ||
.addCString('user') | ||
.addCString(config.user) | ||
.addCString('database') | ||
.addCString(config.database) | ||
.addCString('client_encoding') | ||
.addCString("'utf-8'") | ||
.addCString('').flush(); | ||
; | ||
Object.keys(config).forEach(function(key){ | ||
var val = config[key]; | ||
writer.addCString(key).addCString(val); | ||
}); | ||
writer.addCString('client_encoding').addCString("'utf-8'"); | ||
var bodyBuffer = writer.addCString('').flush(); | ||
//this message is sent without a code | ||
@@ -132,0 +135,0 @@ |
@@ -41,3 +41,6 @@ var defaults = module.exports = { | ||
ssl: false | ||
ssl: false, | ||
application_name : undefined, | ||
fallback_application_name: undefined | ||
}; | ||
@@ -44,0 +47,0 @@ |
@@ -72,2 +72,3 @@ var arrayParser = require(__dirname + "/arrayParser.js"); | ||
} | ||
return date; | ||
@@ -74,0 +75,0 @@ }; |
{ | ||
"name": "pg.js", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "node-postgres without the bindings", | ||
@@ -9,2 +9,7 @@ "main": "index.js", | ||
}, | ||
"homepage": "http://github.com/brianc/node-postgres-pure", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/brianc/node-postgres-pure.git" | ||
}, | ||
"author": "Brian M. Carlson", | ||
@@ -11,0 +16,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
77321
2516
1