Opened 15 years ago
Closed 15 years ago
#12361 closed (duplicate)
GIS DB query generates invalid SQL on two joins with the same table
Reported by: | wardi | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
from django.contrib.gis.db import models from django.contrib.gis.geos import Point class TestModel(models.Model): objects = models.GeoManager() point = models.PointField() class RefModel(models.Model): objects = models.GeoManager() test1 = models.ForeignKey(TestModel, related_name="test1s") test2 = models.ForeignKey(TestModel, related_name="test2s") bool(RefModel.objects.filter(test1__point=Point(1,0), test2__point=Point(2,0)))
causes a psycopg2.ProgrammingError: Missing FROM-clause entry for table "T3"
If point is a CharField or other non-GIS field there is no error. There is also no error if I don't use GeoManager instances (which is itself incorrect in this case).
Note:
See TracTickets
for help on using tickets.
Duplicate of #11741. A patch will be available after multi-db lands.