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
bytea support, not 1 : 1 in javascript/native #184
Comments
exactly same issue here. So how to properly save bytea data? In statement with parameters provided data is cut in native mode. |
In both modes (js and native) works following solution: conn.query('select byteaResult ...', function(err, res){ |
Waterline supports binary datatypes, so map them to BYTEA column types in Postgres. Convert buffers to hex strings (as per the tradition in node-postgres) starting with \x, which will automatically be converted back into Buffer objects when read from Postgres by node-postgres. See brianc/node-postgres#184 and parseByteA of https://github.com/brianc/node-postgres/blob/master/lib/types/textParsers.js
I think this is fixed, right? node-pg-types has had a byte array parser for quite a while. |
In native, it kind of works how you would've figure it should work...
It wants a byte array or else your data will get clipped. It'll give you back a Buffer of the literal string byte array you gave it. So you need to convert this back.
In javascript, it'll take anything, it'll treat it as string, that means it'll complain about non escaped text. It'll give you back a string. You'd have to escape this or encode it as hex or base64. Then decode it later when you retrieve it.
The text was updated successfully, but these errors were encountered: