1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #28659 -- Fixed LayerMapping crash with null geometry and unique.

This commit is contained in:
Melvyn Sopacua
2018-06-19 14:21:39 +02:00
committed by Tim Graham
parent c72dde41e6
commit e7a56eb4f0
3 changed files with 20 additions and 5 deletions

View File

@@ -310,6 +310,17 @@ class LayerMapTest(TestCase):
self.assertEqual(City.objects.count(), 1)
self.assertEqual(City.objects.all()[0].name, "Zürich")
def test_null_geom_with_unique(self):
"""LayerMapping may be created with a unique and a null geometry."""
State.objects.bulk_create([State(name='Colorado'), State(name='Hawaii'), State(name='Texas')])
hw = State.objects.get(name='Hawaii')
hu = County.objects.create(name='Honolulu', state=hw, mpoly=None)
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
lm.save(silent=True, strict=True)
hu.refresh_from_db()
self.assertIsNotNone(hu.mpoly)
self.assertEqual(hu.mpoly.ogr.num_coords, 449)
class OtherRouter:
def db_for_read(self, model, **hints):