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

"invalid message" when string contains NUL char code #720

Closed
evgeni-k opened this issue May 1, 2020 · 1 comment
Closed

"invalid message" when string contains NUL char code #720

evgeni-k opened this issue May 1, 2020 · 1 comment

Comments

@evgeni-k
Copy link

evgeni-k commented May 1, 2020

Expected behavior

be able to insert data

Actual behavior

"invalid message" error is thrown with error code 08P01

Steps to reproduce

String value contains following record
"value\0"

pgp.helpers.insert(values, columnsSet);

Environment

  • Version of pg-promise: 10.5.1
  • OS type (Linux/Windows/Mac): Mac
  • Version of Node.js: 12.6
@vitaly-t
Copy link
Owner

vitaly-t commented May 1, 2020

It is strictly the driver issue. This library can't, and should not do anything about it.

In short, PostggreSQL treats \0 as the string termination. The only proper way to pass string data with zeros is as binary, i.e. as bytea, which then will use Buffer as input, which will be escaped correctly. But regular strings cannot contain zeros.

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

No branches or pull requests

2 participants