Skip to content

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

Open
cgunther wants to merge 1 commit into
diogob:masterfrom
cgunther:fix-selecting_distance_from-rails-6.1
Open

Only join to through_table from selecting_distance_from when there is one#48
cgunther wants to merge 1 commit into
diogob:masterfrom
cgunther:fix-selecting_distance_from-rails-6.1

Conversation

@cgunther
Copy link
Copy Markdown

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
Copy Markdown

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