Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass buffers as parameters #52

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lukaslihotzki
Copy link

Without this commit, buffers passed as parameters are processed like null-terminated strings.

Without this commit, buffers passed as parameters are processed
like null-terminated strings.
@brianc
Copy link
Owner

brianc commented Apr 5, 2017

Hey @lukaslihotzki I appreciate the pull request! Would you be able to provide a test for this? Otherwise I'm not going to be able to accept a patch because the risk of regressions is too high!

Thanks again! ❤️ 😄

@lukaslihotzki
Copy link
Author

Writing the test I noticed buffers in results still are passed as hex strings, but passing raw buffers there would require much more refactoring across different libraries (at least node-pg-types and node-libpq) and then everything, including numbers, etc., had to be parsed from binary.
At least, this commit makes node-postgres interface consistent (buffers as parameters and buffers as result).

@danielgavrilov
Copy link

Is this getting merged? Would be happy to contribute more tests if that's what's holding it back!

We ran into this problem trying to store user-generated CSV files with native bindings on node-postgres. Having a \ (backslash) in a parameter can fail with

ERROR:  invalid input syntax for type bytea

Non-native bindings handle this fine and do exactly the same as this pull request (source).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants