Skip to content

Respect distance units when ordering by distance#50

Open
cgunther wants to merge 1 commit intodiogob:masterfrom
cgunther:order-by-distance_unit
Open

Respect distance units when ordering by distance#50
cgunther wants to merge 1 commit intodiogob:masterfrom
cgunther:order-by-distance_unit

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