Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1131

Fix inconsistent handling of bson.code.Code with explicit empty scope

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      Two problems...

      1. There is no way to encode Code with explicit empty scope to BSON type 0x0F. Code with explicit empty scope (Code("", {})) is always stored as BSON type 0x0D.
      2. json_util always exports Code with $scope.

      The solution is probably to set bson.code.Code.__scope to None when Code was created without an explicit scope, then have the bson encoder and json_util treat None and {} separately. Also add a warning in the changelog, since bson.code.Code.scope currently always returns a dict.

            Assignee:
            luke.lovett Luke Lovett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: