Skip to content

array parser does not handle commas in text properly #99

Closed
jzimmek opened this Issue Feb 17, 2012 · 2 comments

2 participants

@jzimmek
jzimmek commented Feb 17, 2012

It seems that something is wrong in the parser for text arrays. A text element containing a "," character will be interpreted as new element. i have not digged deeply in the node-postgres source, but found "test/integration/client/array-test.js"

this will break as soon as i add a "," in the array element:

change from:
client.query('INSERT INTO why(names, numbors) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\')').on('error', console.log);

change to:
client.query('INSERT INTO why(names, numbors) VALUES(\'{"aaron, INCLUDING COMMA", "brian","a b c" }\', \'{1, 2, 3}\')').on('error', console.log);

is this a known issue and maybe there is already a patch / fix ?

regards
jan

@booo
Collaborator
booo commented Feb 17, 2012

I think this is more or less a know issue. Once someone started implementing a simple regex for the complex array parsing problem. He missed some cases and now people try to improve it little by little.

If you want to provide us with a proper test case you should take a look at https://github.com/brianc/node-postgres/blob/master/test/unit/client/query-tests.js

There is also the binary query mode that should support arrays a bit better but maybe causes perfomance issues.

Regards
Philipp

@jzimmek
jzimmek commented Feb 28, 2012

fixed by #100

@jzimmek jzimmek closed this Feb 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.