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
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema #42429
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema #42429
Conversation
b89c7da
to
4d57880
Compare
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Show resolved
Hide resolved
f166b36
to
5ef4ca8
Compare
Is this bugfix something we'd consider worth to be backported to 6.1 / 5.2 ? |
cd3ff87
to
bcef98b
Compare
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
+1 |
bcef98b
to
0fb9302
Compare
I rebased it onto main.. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
+1 |
c6c0304
to
a2f5aee
Compare
I rebased it onto main. |
a2f5aee
to
405075e
Compare
…MySQL schema Mysql automatically escapes quotes in generated check constraints expressions. When Rails dumps the schema (into schema.rb) the generated schema also contains, the quotes with duplicated escaping (\\\\'). To fix this, we remove the escaping, that MySQL provides from the fetched expression.
405075e
to
468d3d0
Compare
Fix duplicate escaping of quotes for check constraint expressions in MySQL schema
Summary
Mysql automatically escapes quotes in generated check constraints expressions.
When Rails dumps the schema (into schema.rb) the generated schema also contains
the quotes with duplicated escaping (\\').
To fix this, we remove the escaping that MySQL provides from the fetched expression.
Fixes #42424
Other Information
I decided to go with an MySQL specific test, because putting it in https://github.com/rails/rails/blob/6-1-stable/activerecord/test/cases/migration/check_constraint_test.rb leads to code like this:
As the code shows, even MariaDB handles the quoting differently than MySQL.