Skip to content

Respect distance units when ordering by distance #50

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

While the unit shouldn't change the result, if you order and select with a distinct call (ie. Model.distinct.selecting_distance_from(...).order_by_distance(...)), Postgres requires all ordering values to also be selected.

Previously, in such a case, we'd be selecting by miles when that was the configured unit, but then ordering by meters, which Postres didn't like.

Now, we'll both select miles and order by miles when configured as such.

While the unit shouldn't change the result, if you order and select with
a distinct call (ie. `Model.distinct.selecting_distance_from(...).order_by_distance(...)`),
Postgres requires all ordering values to also be selected.

Previously, in such a case, we'd be selecting by miles when that was the
configured unit, but then ordering by meters, which Postres didn't like.

Now, we'll both select miles and order by miles when configured as such.
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.

1 participant