-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Python Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
Context
Adapter.init() in django_mongodb_backend/gis/adapter.py special-cases a top-level GeometryCollection and emits a geometries list, but the per-member get_data() helper is not recursive: it unconditionally emits:
{"type": ..., "coordinates": obj.coords}
As a result, a GeometryCollection nested inside another GeometryCollection is serialized with a coordinates key instead of geometries, which is not valid GeoJSON:
{ type: "GeometryCollection", coordinates: [ [ [ [ [ 0.0, 0.0 ] ] ] ] ] }
MongoDB rejects nested {{GeometryCollection}}s outright (server error 16755, "GeometryCollections cannot be nested"), so no user can successfully store one regardless of how it is serialized. The only visible consequence is that the server-side error message reports a malformed shape, which is misleading when debugging.
Definition of done
Make get_data() recurse when obj is a GeometryCollection, returning a geometries list instead of coordinates. This would collapse the special case in _init() into the general path. Note that fixing this will _not make the skipped test pass — the insert still fails with 16755 — so this is a correctness/diagnostics cleanup only.
Pitfalls
None