不要怂,就是干,撸起袖子干!

You need to sign in or sign up before continuing.
Commit 3970bf71 by Mick Hansen

Merge pull request #2039 from sentencesio/useless-pg-connection-string

pg: remove the useless connection string
2 parents 40e0769e bec48757
Showing with 28 additions and 3 deletions
......@@ -19,11 +19,36 @@ ConnectionManager = function(dialect, sequelize) {
Utils._.extend(ConnectionManager.prototype, AbstractConnectionManager.prototype);
ConnectionManager.prototype.connect = function(config) {
var self = this;
var self = this
, connectionConfig = {};
config.user = config.username;
connectionConfig = Utils._.pick(config, [
'user', 'password', 'host', 'database', 'port'
]);
if (config.dialectOptions) {
Utils._.merge(connectionConfig,
Utils._.pick(config.dialectOptions, [
// see [http://www.postgresql.org/docs/9.3/static/runtime-config-logging.html#GUC-APPLICATION-NAME]
'application_name',
// choose the SSL mode with the PGSSLMODE environment variable
// object format: [https://github.com/brianc/node-postgres/blob/master/lib/connection.js#L79]
// see also [http://www.postgresql.org/docs/9.3/static/libpq-ssl.html]
'ssl',
// In addition to the values accepted by the corresponding server,
// you can use "auto" to determine the right encoding from the
// current locale in the client (LC_CTYPE environment variable on Unix systems)
'client_encoding',
// !! DONT SET THIS TO TRUE !!
// (unless you know what you're doing)
// see [http://www.postgresql.org/message-id/flat/bc9549a50706040852u27633f41ib1e6b09f8339d845@mail.gmail.com#bc9549a50706040852u27633f41ib1e6b09f8339d845@mail.gmail.com]
'binary'
]));
}
return new Promise(function (resolve, reject) {
var connectionString = self.sequelize.getQueryInterface().QueryGenerator.databaseConnectionUri(config)
, connection = new self.lib.Client(connectionString)
var connection = new self.lib.Client(connectionConfig)
, responded = false;
connection.connect(function(err) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!