Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upLatin 1 client encoding support for the pure JavaScript client #2215
Conversation
@@ -6,7 +6,11 @@ var utils = require(__dirname + '/../../../lib/utils') | |||
var connect = function (callback) { | |||
var username = helper.args.user | |||
var database = helper.args.database | |||
var con = new Connection({ stream: new net.Stream() }) | |||
var client_encoding = helper.args.client_encoding |
This comment has been minimized.
This comment has been minimized.
brianc
May 13, 2020
Owner
I see you're passing this in here which is cool, but were you intending on setting this in CI to test both permutations? AFAIK this will always still default to utf-8
for now?
This comment has been minimized.
This comment has been minimized.
boromisp
May 13, 2020
Author
Contributor
I haven't considered how to test it. Would it be better to write a few targeted integration and unit tests instead of running all the tests with different client encodings?
This comment has been minimized.
This comment has been minimized.
brianc
Jun 18, 2020
Owner
Would it be better to write a few targeted integration and unit tests instead of running all the tests with different client encodings?
yeah i think so - running the whole test suite again just to test a different encoding is overkill IMO
whoah that was super fast! thanks! LMK if there's anything else you want me to take a look at or any additional tests you'd like me to write. I left a touch of feedback on there but this is fabulous. |
@brianc I've made a couple of improvements:
There is a known bug in the current implementation: If the user sets the The simplest way to handle this error would be to terminate the connection, but I'm not sure how to propagate this error to the As an aside, since the only use-case for this code seems to be supporting misconfigured databases ( |
Hey sorry for the delay! I was out on vacation & just getting back...I'll take a look at this tomorrow! |
boromisp commentedMay 13, 2020
This PR fixes the handling of the
client_encoding
parameter in the pure JavaScript client.The intersection of the natively supported text encodings of Node.js and Postgres is UTF-8 and Latin 1.
The main (only?) use-case for this is compatibility with existing
SQL_ASCII
databases containingLATIN1
encoded text.I've could not get the native client working.
Related issues: #2203 (#2204 unconfirmed)