Skip to content

Only join to through_table from selecting_distance_from when there is one #48

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cgunther
Copy link

Prior to Rails 6.1, the arguments to joins! were compacted, so if you called selecting_distance_from directly on the geolocated model where through_table was nil, it'd be compacted away and a join wouldn't actually be attempted.

Since Rails 6.1, the arguments to joins! are no longer compacted, so a join will be attempted to nil in such a case, leading to an error.

Now we'll only join to the through_table if there actually is one.

Here's the relevant Rails commit:
rails/rails@6038755

Once #47 is merged, this can be rebased to show it'll fix the failing specs.

…e is one

Prior to Rails 6.1, the arguments to `joins!` were compacted, so if you
called `selecting_distance_from` directly on the geolocated model where
`through_table` was `nil`, it'd be compacted away and a join wouldn't
actually be attempted.

Since Rails 6.1, the arguments to `joins!` are no longer compacted, so a
join will be attempted to `nil` in such a case, leading to an error.

Now we'll only join to the `through_table` if there actually is one.

Here's the relevant Rails commit:
rails/rails@6038755
@fpjoe
Copy link

fpjoe commented Mar 30, 2023

I ran into this issue as well. Your fix looks perfect. Any word on when this might be mergeable? (Noticed it's waiting on #47)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants