ExportXMLWordPrintableJSON

    • None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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

            Assignee:
            Steve Silvester
            Reporter:
            Alex Clark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: