Opened 3 years ago

Closed 3 years ago

#18704 closed Bug (needsinfo)

Distance lookups fail when used with LIMIT statements

Reported by: dloewenherz Owned by: nobody
Component: GIS Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


To repro, just create a geomanaged model and try the following statements.

Place.objects.filter(coordinates__distance_lte=(pnt, D(mi=2)))

Should work, with pnt being an arbitrary coordinate (Point). Now, try something like the following.

Place.objects.filter(coordinates__distance_lte=(pnt, D(mi=2)))[:3]

It will fail with "GEOSException: Error encountered checking Coordinate Sequence returned from GEOS C function".


Change History (4)

comment:1 Changed 3 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

I was not able to reproduce this error. You can find similar tests around Reopen if you can provide more details to reproduce it.

comment:2 Changed 3 years ago by dloewenherz

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Yes, those tests work fine, and like I said in the original description, regular distance lookups work perfectly.

However, they don't test limit queries, which is where the exception occurs. I'm pretty sure this is a query formatting issue, since the normal lookup works. If the normal lookup didn't work, I'd say it was a configuration error or something on my end.

I'll add a working test case in the next comment.

comment:3 Changed 3 years ago by claudep

I did add slicing in the aforementioned tests without generating any error, so I would be interested to read a failing test example.

comment:4 Changed 3 years ago by claudep

  • Resolution set to needsinfo
  • Status changed from reopened to closed

Still waiting for a failing test case...

Note: See TracTickets for help on using tickets.
Back to Top