diff options
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 |
