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
Quote binary strings in Arel #47493
Quote binary strings in Arel #47493
Conversation
Tests are failing, can you take a look? 🙇
|
@zzak Yes, sorry, I should have posted earlier on this PR that we found out about that after creating the PR. Sorry about that. We'll definitely look into fixing this! I've changed the status of the PR to draft while we're working out the kinks so it doesn't get merged by error. |
3fe6af6
to
7ea24dc
Compare
7ea24dc
to
3cd3d2e
Compare
3cd3d2e
to
d4aa1b3
Compare
We should properly hex-encode binary strings for SQLite3 and MySQL. For e.g. MySQL, _not_ doing that _may_ work, but it will also produce database warnings.
In Ruby 2.7, `BigDecimal#to_s` generates ASCII-8BIT-encoded strings. We don't want those to get hex-encoded in the generated SQL.
d4aa1b3
to
a865520
Compare
@zzak the PR is now in a proper shape for review! |
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.
Just a minor nitpick, but LGTM.
a865520
to
f424273
Compare
Motivation / Background
When binding binary strings in Arel, we want the data to be properly quoted, otherwise we will generate e.g. MySQL warnings.
Detail
When quoting strings, we now check if they are binary-encoded, and if so, we quote them using the native binary representation.
Co-authored with @matthewd.
Additional information
There is a bit of duplication in the quotation logic between adapters and
Type::Binary::Data
. Ideas for reducing this without causing additional coupling will be appreciated!Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.