-
Notifications
You must be signed in to change notification settings - Fork 41
Support binary data #164
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
Support binary data #164
Conversation
This handles better for BLOB type columns. Without this, it basically would have only worked for ASCII binary data since it gets Buffer.toString()'d, but then does an extra quoting and sanitization pass. For binary data, which we can assume is coming from a Buffer, we want to send as hexadecimal. Fixes #161
|
Ok, the fundamental issue with this solution is that I think we need to do something to deal with this as an ArrayBuffer or Uint8Array ? I'm not sure if we can feature-detect and allow |
81daa57 to
8d0ba85
Compare
|
We should be able to add some trivial unit tests for this to confirm behavior. |
9f46615 to
0e46242
Compare
0e46242 to
de52a28
Compare
|
|
||
| export function cast(field: Field, value: string | null): any { | ||
| if (value === '' || value == null) { | ||
| if (value == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to handle empty strings when it's binary data and not just return an empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, see my comment below.
|
|
||
| export function cast(field: Field, value: string | null): any { | ||
| if (value === '' || value == null) { | ||
| if (value == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, see my comment below.
This handles better for BLOB type columns. Without this, it basically would have only worked for ASCII binary data since it gets Buffer.toString()'d, but then does an extra quoting and sanitization pass.
For binary data, which we can assume is coming from a Uint8Array, we want to send as hexadecimal.
Fixes #161