Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix it so passwordless connections work #77

Merged
merged 1 commit into from

2 participants

@bjourne

...ementation. the connection string formatting is changed so that it is possible to connect to pg without supplying credentials over a domain socket

@bjourne bjourne use node-postgres "native" libpq api instead of the pure javascript i…
…mplementation. the connection string formatting is changed so that it is possible to connect to pg without supplying credentials over a domain socket
b3a9c66
@dresende
Owner

Could you just remove the console.log about the connection string?

@dresende dresende referenced this pull request from a commit
@dresende Merging #77 with some modifications
- removed console.log
- can't use native right now, there's no way to know if native is
installed (it doesn't work for me..)
baf7c54
@dresende dresende referenced this pull request from a commit
@dresende Merge branch 'pr/77'
* pr/77:
  Merging #77 with some modifications
  use node-postgres "native" libpq api instead of the pure javascript implementation. the connection string formatting is changed so that it is possible to connect to pg without supplying credentials over a domain socket
0eed10a
@dresende dresende merged commit b3a9c66 into from
@dresende
Owner

If you know how to detect if pg.native works tell me. I know it's there but there's no flag or something to inform me I can use it. And it doesn't fallback either.

You can for now do:

var orm = require("orm");
var pg = require("pg").native;
var client = new pg.Client(....);

client.connect(function () {
    orm.connect(pg, function (_, db) {
        // ready!
        db.define(...);
    });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 21, 2012
  1. @bjourne

    use node-postgres "native" libpq api instead of the pure javascript i…

    bjourne authored
    …mplementation. the connection string formatting is changed so that it is possible to connect to pg without supplying credentials over a domain socket
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 16 deletions.
  1. +10 −16 lib/databases/postgresql.js
View
26 lib/databases/postgresql.js
@@ -365,15 +365,7 @@ DBClient.prototype.end = function () {
};
exports.connect = function (options, callback) {
- var pg = require("pg");
- var opts = {
- "host" : "localhost",
- "port" : 5432,
- "user" : "postgres",
- "password" : "",
- "database" : "postgres"
- };
-
+ var pg = require("pg").native;
if (options.auth) {
var p;
if ((p = options.auth.indexOf(":")) != -1) {
@@ -390,13 +382,15 @@ exports.connect = function (options, callback) {
options.host = options.hostname;
}
- for (var k in options) {
- if (opts.hasOwnProperty(k)) {
- opts[k] = options[k];
- }
- }
-
- var client = new pg.Client("pg://"+opts.user+":"+opts.password+"@"+opts.host+":"+opts.port+"/"+opts.database);
+ var connectionString =
+ "pg://"
+ + (options.user ? options.user : "")
+ + (options.password ? ":" + options.password : "")
+ + (options.host ? "@" + options.host : "")
+ + (options.port ? ":" + options.port : "")
+ + "/" + options.database;
+ console.log('connection = ' + connectionString);
+ var client = new pg.Client(connectionString);
var errorListener = function(err) {
callback(false, { "number": parseInt(err.code, 10), "message": err.message });
};
Something went wrong with that request. Please try again.