Closed kshahkshah closed 6 years ago
Thanks for the bug report, @whistlerbrk. Glancing at the stack trace, I think that some minor refactoring in ActiveRecord is the cause of this issue.
Can you confirm that running ActiveRecord::QueryMethods::DEFAULT_VALUES[:distinct_on] = ActiveRecord::QueryMethods::FROZEN_EMPTY_ARRAY
in the console solves the problem?
If so, I'll release a new version with the necessary modifications.
I think this is what caused the problem.
https://github.com/rails/rails/commit/df712340bde5ee306456099e0a8e47762515f9c3
Since they are now memoizing values upon load, this monkey patch doesn't add the lookup to the cache any more (because we've already built up the cache by the time the gem is activated).
I performed the hack you suggested and it fixed the problem, so I think that's a shippable change.
I think you'll want do do a version check against Rails for adding to DEFAULT_VALUES
since it doesn't exist prior to 5.1.5.
Or just do an existence check for ActiveRecord::QueryMethods::DEFAULT_VALUES
@whistlerbrk A fix for this issue has been released in 0.1.3. :tada:
Hello, apologies in advance for the lame description and weak stack trace I'm going to provide.
I upgraded from Rails 5.1.2 to 5.1.5 and pg 0.21 to pg 1.0.0 and all appeared to be fine, however upon deleting a user, and note the User model does not use AR Distinct On nor does it cascade and cause other models to, an error was raised.
ArgumentError: unknown relation value :distinct_on
I solved this of course by reverting. And while I recognize that this gem was not directly in the stack trace, it appears that is may be involved? So at the least I'm documenting here for others. Will also open an issues at rails/rails/