1

pg-promise does not understand UTF passwords?.. I can't make it work with them. Tried on linux and osx, postgres 9.3, 9.5 - seems to be not specific to versions. Looked into code. pg-promise uses pg, which uses pg-connect-string which is build based on back pg. Can't find the the root of the problem. Please help.

code to reproduce:

MacBook-Air:js vao$ cat 2.js
var pgp = require("pg-promise")();
var cs = 'postgresql://utf:утф@127.0.0.1:5433/a';
var db = pgp(cs);
db.connect()
    .then(function (obj) {
        obj.done(); // success, release the connection;
    })
    .catch(function (error) {
        console.log("ERROR:", error.message || error);
    });
console.log(cs);

returns:

MacBook-Air:js vao$ node 2.js
postgresql://utf:утф@127.0.0.1:5433/a
ERROR: password authentication failed for user "utf"

Using same connection string with psql:

MacBook-Air:js vao$ psql 'postgresql://utf:утф@127.0.0.1:5433/a'
psql (9.5.3)
Type "help" for help.

a=> \q

Trying bad password deliberately with same connection string:

MacBook-Air:js vao$ psql 'postgresql://utf:утфWrongPassword@127.0.0.1:5433/a'
psql: FATAL:  password authentication failed for user "utf"
MacBook-Air:js vao$
Vao Tsun
  • 47,234
  • 13
  • 100
  • 132

1 Answers1

0

As the author of pg-promise, I'd like at least to offer some guidance here on where to look, not the exact answer, as I've never dealt with UTF passwords myself.

pg-promise uses node-postgres, which in turn uses pg-connection-string to parse the connection. If there is an issue, then it is most likely inside pg-connection-string.

I would recommend trying Unicode notation that relies on %. Maybe it will work. Maybe not, I've never tried. Also the following question was never answered: Node.js postgres UTF connect string, which isn't reassuring either.

Sorry, I cannot be of more help at present.

Community
  • 1
  • 1
vitaly-t
  • 24,279
  • 15
  • 116
  • 138