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
Using table_name_prefix with hyphen causes MySQL error #3163
Comments
Hi! @bostrom |
Anyway, I sent PR :) |
Thanks for the fix! But actually I solved it another way (probably the right way). I figured that using another database by prefixing the table name with the database name isn't the right way to go. Instead I defined the other database in But this fix might be relevant in other cases also, so a PR is probably not a bad idea anyways. |
Fix GH #3163. Should quote database on mysql/mysql2.
Conflicts: activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
Conflicts: activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb
Conflicts: activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb Conflicts: activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb activerecord/lib/active_record/connection_adapters/mysql_adapter.rb activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb activerecord/test/cases/adapters/mysql2/schema_test.rb
Using Rails 3.0.10 with a table name prefix that includes a hyphen. This is set up in the model class like
which works perfectly fine under certain circumstances. However, when ActiveRecord (or more correctly the MySQL adapter) constructs the sql for a query with, for example, an order by statement, it doesn't quote the prefix with backticks, which makes MySQL choke on the query.
Note the unquoted my-db in the queries.
A possible partial fix for this would be to add
to the tables method of mysql_adapter.rb, like so:
The text was updated successfully, but these errors were encountered: