0
0
mirror of https://github.com/django/django.git synced 2024-11-24 02:47:35 +01: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:
David Smith 2024-01-11 18:29:38 +00:00
parent 51806359db
commit b0f869891c

View File

@ -646,6 +646,14 @@ class LayerMapping:
else:
geom = geom_value.ogr
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:
geom.add(g)
setattr(m, self.geom_field, geom.wkt)