ransack
ransack copied to clipboard
Delegate alias_tracker creation to AR Relation rather than doing it ourselves
Closes #1491.
This PR is addressing an error we are experiencing on edge rails. This error is caused because the API for creating an ActiveRecord::Associations::AliasTracker
has changed in edge rails. It now wants to eat a connection pool rather than a connection. Knowing nothing about ransack's internals, from what I can tell it shouldn't need to use this API directly, and should just ask it's ActiveRecord::Relation
to create a fresh AliasTracker
instead. This patch includes my naive way of doing so. It fixes the breakages in our own test suite. Please let me know if there are other additions I should include.
This branch makes activeadmin specs pass:
https://github.com/activeadmin/activeadmin/pull/8371/files#diff-d09ea66f8227784ff4393d88a19836f321c915ae10031d16c93d67e6283ab55fR16
https://github.com/activeadmin/activeadmin/actions/runs/9438394298/job/25995318087
This modification solved my problem of undefined method `with_connection' for an instance of ActiveRecord::ConnectionAdapters::PostgreSQLAdapter in rails 7.2
@robinator thanks for your contribution! We needed some other changes too to make it work with Rails 7.2 so I cherry-picked your commit in #1503 and closing this one.