diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-07-19 10:28:56 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-20 09:05:45 -0400 |
| commit | 9415fcfef64b42fbd8c5cb7fff57911a4cda2300 (patch) | |
| tree | aa42e4530170484dec354ec8babe0d28e387a4ee | |
| parent | 37fbeb99f9cb834dda9a1a753af0a832f2bc5f7e (diff) | |
Tested the case when the lhs of a raster lookup has an index specified and the rhs doesn't.
| -rw-r--r-- | tests/gis_tests/rasterapp/test_rasterfield.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/gis_tests/rasterapp/test_rasterfield.py b/tests/gis_tests/rasterapp/test_rasterfield.py index f77c9ae6e8..4fba577f5e 100644 --- a/tests/gis_tests/rasterapp/test_rasterfield.py +++ b/tests/gis_tests/rasterapp/test_rasterfield.py @@ -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\)') |
