mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed LayerMapping with Oracle 23c.
Oracle 23c collapses MULTI geometries with only one entry to their non-MULTI type. Added check when loading geometries from the database that a MULTI type is returned. Reconvert to correct geometry type, if required.
This commit is contained in:
parent
51806359db
commit
b0f869891c
@ -646,6 +646,14 @@ class LayerMapping:
|
|||||||
else:
|
else:
|
||||||
geom = geom_value.ogr
|
geom = geom_value.ogr
|
||||||
new = OGRGeometry(kwargs[self.geom_field])
|
new = OGRGeometry(kwargs[self.geom_field])
|
||||||
|
if (
|
||||||
|
geom_typeid := geom.geos.geom_typeid
|
||||||
|
) in self.MULTI_TYPES:
|
||||||
|
# Database returned non-MULTI type, reconvert.
|
||||||
|
multi_type = self.MULTI_TYPES[geom_typeid]
|
||||||
|
g = OGRGeometry(multi_type)
|
||||||
|
g.add(geom)
|
||||||
|
geom = g
|
||||||
for g in new:
|
for g in new:
|
||||||
geom.add(g)
|
geom.add(g)
|
||||||
setattr(m, self.geom_field, geom.wkt)
|
setattr(m, self.geom_field, geom.wkt)
|
||||||
|
Loading…
Reference in New Issue
Block a user