diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2017-04-01 22:43:53 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-04-01 13:43:53 -0400 |
| commit | 0a13b249e2e0e901d795f4198a3a5dfd1fc49554 (patch) | |
| tree | d1c68e2adfb3f920c133e7124c368264d3360ba1 /django | |
| parent | 9a9e22832166594e3561fa1911dd255a2fb09b2b (diff) | |
Fixed #26967 -- Added MySQL support for AsGeoJSON, GeoHash, IsValid functions, and isvalid lookup.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/mysql/operations.py | 9 | ||||
| -rw-r--r-- | django/contrib/gis/db/models/functions.py | 7 |
2 files changed, 12 insertions, 4 deletions
diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index 6408d76fa4..58aeda4deb 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -72,11 +72,12 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations): @cached_property def unsupported_functions(self): unsupported = { - 'AsGeoJSON', 'AsGML', 'AsKML', 'AsSVG', 'BoundingCircle', - 'ForceRHR', 'GeoHash', 'IsValid', 'MakeValid', 'MemSize', - 'Perimeter', 'PointOnSurface', 'Reverse', 'Scale', 'SnapToGrid', - 'Transform', 'Translate', + 'AsGML', 'AsKML', 'AsSVG', 'BoundingCircle', 'ForceRHR', + 'MakeValid', 'MemSize', 'Perimeter', 'PointOnSurface', 'Reverse', + 'Scale', 'SnapToGrid', 'Transform', 'Translate', } + if self.connection.mysql_version < (5, 7, 5): + unsupported.update({'AsGeoJSON', 'GeoHash', 'IsValid'}) if self.is_mysql_5_5: unsupported.update({'Difference', 'Distance', 'Intersection', 'SymDifference', 'Union'}) return unsupported diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py index dcd09472e3..c595a143d0 100644 --- a/django/contrib/gis/db/models/functions.py +++ b/django/contrib/gis/db/models/functions.py @@ -330,6 +330,13 @@ class GeoHash(GeoFunc): expressions.append(self._handle_param(precision, 'precision', int)) super().__init__(*expressions, **extra) + def as_mysql(self, compiler, connection): + clone = self.copy() + # If no precision is provided, set it to the maximum. + if len(clone.source_expressions) < 2: + clone.source_expressions.append(Value(100)) + return clone.as_sql(compiler, connection) + class Intersection(OracleToleranceMixin, GeomOutputGeoFunc): arity = 2 |
