diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2016-06-17 20:03:50 +0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-12-06 13:58:22 -0500 |
| commit | 183f5015408ffe0d3a22203ddaf7a3a56da025fd (patch) | |
| tree | e0c7c7bde6fc7e41a95b3167d5d6213c456a7d2d /django | |
| parent | b90d72facf1e4294df1c2e6b51b26f6879bf2992 (diff) | |
Fixed #26789 -- Fixed handling of empty geometries in BaseSpatialField.get_db_prep_save().
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backends/base/features.py | 2 | ||||
| -rw-r--r-- | django/contrib/gis/db/backends/postgis/features.py | 1 | ||||
| -rw-r--r-- | django/contrib/gis/db/models/fields.py | 6 |
3 files changed, 6 insertions, 3 deletions
diff --git a/django/contrib/gis/db/backends/base/features.py b/django/contrib/gis/db/backends/base/features.py index 451b515625..3d1dfba1dd 100644 --- a/django/contrib/gis/db/backends/base/features.py +++ b/django/contrib/gis/db/backends/base/features.py @@ -26,6 +26,8 @@ class BaseSpatialFeatures(object): supports_real_shape_operations = True # Can geometry fields be null? supports_null_geometries = True + # Are empty geometries supported? + supports_empty_geometries = False # Can the the function be applied on geodetic coordinate systems? supports_distance_geodetic = True supports_length_geodetic = True diff --git a/django/contrib/gis/db/backends/postgis/features.py b/django/contrib/gis/db/backends/postgis/features.py index ea1d450008..2d613efe6e 100644 --- a/django/contrib/gis/db/backends/postgis/features.py +++ b/django/contrib/gis/db/backends/postgis/features.py @@ -8,3 +8,4 @@ class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): supports_3d_functions = True supports_left_right_lookups = True supports_raster = True + supports_empty_geometries = True diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index a3813edd58..7519b30fb2 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -177,10 +177,10 @@ class BaseSpatialField(Field): """ Prepare the value for saving in the database. """ - if not value: - return None - else: + if isinstance(value, Geometry) or value: return connection.ops.Adapter(self.get_prep_value(value)) + else: + return None def get_raster_prep_value(self, value, is_candidate): """ |
