Skip to content
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 encoding detection error for MySQL applications using a connection proxy #3313

Merged

Commits on Oct 9, 2020

  1. Use raw_connection to retrieve encoding for mysql2 client

    Applications using MySQL and DB connection proxies (such as [active_record_host_pool](https://github.com/zendesk/active_record_host_pool/blob/76c244ddb1d7b5736fe0d043b98e33026b9c170f/lib/active_record_host_pool/connection_proxy.rb)) cannot currently use RailsAdmin's export feature, as `instance_variable_get` returns `nil` - resulting in a `NoMethodError` when `#encoding` is called [from the template](https://github.com/sferik/rails_admin/blob/73ac02f7c375f2f446ceb212615ef9056c9cd587/app/views/rails_admin/main/export.html.haml#L59) after a user clicks to export from a list.
    
    `raw_connection` returns the same connection as the `@connection` instance variable, and works with `Delegator`s that wrap the connection. `raw_connection` itself is [supported across all maintained versions of Rails](https://apidock.com/rails/v6.0.0/ActiveRecord/ConnectionAdapters/AbstractAdapter/raw_connection), and resolves the issue mentioned above.
    codealchemy committed Oct 9, 2020
    Configuration menu
    Copy the full SHA
    a316490 View commit details
    Browse the repository at this point in the history