mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.8.x] Fixed #25592 -- Fixed misnamed strictly_above PostGIS lookup
Fixes a regression from2bd1bbc42. Thanks Daniel Wiesmann for the report and Tim Graham for the review. Backport ofc08f85fd54from master.
This commit is contained in:
		| @@ -67,7 +67,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): | |||||||
|         'left': PostGISOperator(op='<<'), |         'left': PostGISOperator(op='<<'), | ||||||
|         'right': PostGISOperator(op='>>'), |         'right': PostGISOperator(op='>>'), | ||||||
|         'strictly_below': PostGISOperator(op='<<|'), |         'strictly_below': PostGISOperator(op='<<|'), | ||||||
|         'stricly_above': PostGISOperator(op='|>>'), |         'strictly_above': PostGISOperator(op='|>>'), | ||||||
|         'same_as': PostGISOperator(op='~='), |         'same_as': PostGISOperator(op='~='), | ||||||
|         'exact': PostGISOperator(op='~='),  # alias of same_as |         'exact': PostGISOperator(op='~='),  # alias of same_as | ||||||
|         'contains_properly': PostGISOperator(func='ST_ContainsProperly'), |         'contains_properly': PostGISOperator(func='ST_ContainsProperly'), | ||||||
|   | |||||||
| @@ -34,3 +34,6 @@ Bugfixes | |||||||
|   and retrieval (:ticket:`25563`). This prevents any models generated in data |   and retrieval (:ticket:`25563`). This prevents any models generated in data | ||||||
|   migrations using ``QuerySet.defer()`` from leaking to test and application |   migrations using ``QuerySet.defer()`` from leaking to test and application | ||||||
|   code. |   code. | ||||||
|  |  | ||||||
|  | * Fixed a typo in the name of the `strictly_above` PostGIS lookup | ||||||
|  |   (:ticket:`25592`). | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ from django.test import TestCase, ignore_warnings, skipUnlessDBFeature | |||||||
| from django.utils import six | from django.utils import six | ||||||
| from django.utils.deprecation import RemovedInDjango110Warning | from django.utils.deprecation import RemovedInDjango110Warning | ||||||
|  |  | ||||||
| from ..utils import no_oracle, oracle, postgis, spatialite | from ..utils import no_oracle, oracle, postgis, skipUnlessGISLookup, spatialite | ||||||
|  |  | ||||||
| if HAS_GEOS: | if HAS_GEOS: | ||||||
|     from django.contrib.gis.db.models import Extent, MakeLine, Union |     from django.contrib.gis.db.models import Extent, MakeLine, Union | ||||||
| @@ -347,6 +347,20 @@ class GeoLookupTest(TestCase): | |||||||
|         for c in qs: |         for c in qs: | ||||||
|             self.assertIn(c.name, cities) |             self.assertIn(c.name, cities) | ||||||
|  |  | ||||||
|  |     @skipUnlessGISLookup("strictly_above", "strictly_below") | ||||||
|  |     def test_strictly_above_below_lookups(self): | ||||||
|  |         dallas = City.objects.get(name='Dallas') | ||||||
|  |         self.assertQuerysetEqual( | ||||||
|  |             City.objects.filter(point__strictly_above=dallas.point).order_by('name'), | ||||||
|  |             ['Chicago', 'Lawrence', 'Oklahoma City', 'Pueblo', 'Victoria'], | ||||||
|  |             lambda b: b.name | ||||||
|  |         ) | ||||||
|  |         self.assertQuerysetEqual( | ||||||
|  |             City.objects.filter(point__strictly_below=dallas.point).order_by('name'), | ||||||
|  |             ['Houston', 'Wellington'], | ||||||
|  |             lambda b: b.name | ||||||
|  |         ) | ||||||
|  |  | ||||||
|     def test_equals_lookups(self): |     def test_equals_lookups(self): | ||||||
|         "Testing the 'same_as' and 'equals' lookup types." |         "Testing the 'same_as' and 'equals' lookup types." | ||||||
|         pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326) |         pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326) | ||||||
|   | |||||||
| @@ -1,13 +1,30 @@ | |||||||
| from unittest import skip | import unittest | ||||||
|  | from functools import wraps | ||||||
|  |  | ||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.db import DEFAULT_DB_ALIAS | from django.db import DEFAULT_DB_ALIAS, connection | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def skipUnlessGISLookup(*gis_lookups): | ||||||
|  |     """ | ||||||
|  |     Skip a test unless a database supports all of gis_lookups. | ||||||
|  |     """ | ||||||
|  |     def decorator(test_func): | ||||||
|  |         @wraps(test_func) | ||||||
|  |         def skip_wrapper(*args, **kwargs): | ||||||
|  |             if any(key not in connection.ops.gis_operators for key in gis_lookups): | ||||||
|  |                 raise unittest.SkipTest( | ||||||
|  |                     "Database doesn't support all the lookups: %s" % ", ".join(gis_lookups) | ||||||
|  |                 ) | ||||||
|  |             return test_func(*args, **kwargs) | ||||||
|  |         return skip_wrapper | ||||||
|  |     return decorator | ||||||
|  |  | ||||||
|  |  | ||||||
| def no_backend(test_func, backend): | def no_backend(test_func, backend): | ||||||
|     "Use this decorator to disable test on specified backend." |     "Use this decorator to disable test on specified backend." | ||||||
|     if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend: |     if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend: | ||||||
|         @skip("This test is skipped on '%s' backend" % backend) |         @unittest.skip("This test is skipped on '%s' backend" % backend) | ||||||
|         def inner(): |         def inner(): | ||||||
|             pass |             pass | ||||||
|         return inner |         return inner | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user