Skip to content

fix(db-postgres): build near sort query properly for point fields #12240

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 2 commits into
base: main
Choose a base branch
from

Conversation

r1tsuu
Copy link
Member

@r1tsuu r1tsuu commented Apr 28, 2025

Continuation of #12185 and fix #12221

The mentioned PR introduced auto sorting by the point field when a near query is used, but it didn't build actual needed query to order results by their distance to a given (from the near query) point.

Now, we build:

order by pont_field <-> ST_SetSRID(ST_MakePoint(lng, lat), 4326)

Which does what we want

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

Successfully merging this pull request may close these issues.

Postgres near operator does not work when neither of max / min distance are specified
1 participant