mirror of https://github.com/django/django.git
Tested the case when the lhs of a raster lookup has an index specified and the rhs doesn't.
This commit is contained in:
parent
37fbeb99f9
commit
9415fcfef6
|
@ -7,8 +7,10 @@ from django.contrib.gis.gdal import GDALRaster
|
|||
from django.contrib.gis.geos import GEOSGeometry
|
||||
from django.contrib.gis.measure import D
|
||||
from django.contrib.gis.shortcuts import numpy
|
||||
from django.db import connection
|
||||
from django.db.models import Q
|
||||
from django.test import TransactionTestCase, skipUnlessDBFeature
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
|
||||
from ..data.rasters.textrasters import JSON_RASTER
|
||||
from .models import RasterModel, RasterRelatedModel
|
||||
|
@ -356,3 +358,10 @@ class RasterFieldTest(TransactionTestCase):
|
|||
msg = "Distance function requires a GeometryField in position 1, got RasterField."
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
RasterModel.objects.annotate(distance_from_point=Distance("rastprojected", point)).count()
|
||||
|
||||
def test_lhs_with_index_rhs_without_index(self):
|
||||
with CaptureQueriesContext(connection) as queries:
|
||||
RasterModel.objects.filter(rast__0__contains=json.loads(JSON_RASTER)).exists()
|
||||
# It's easier to check the indexes in the generated SQL than to write
|
||||
# tests that cover all index combinations.
|
||||
self.assertRegex(queries[-1]['sql'], r'WHERE ST_Contains\([^)]*, 1, [^)]*, 1\)')
|
||||
|
|
Loading…
Reference in New Issue