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

When storing integers, type is selected according to value instead of type

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.10.1
    • Affects Version/s: None
    • Component/s: None
    • None

      if isinstance(value, (int, long)):

      1. TODO this is a really ugly way to check for this...
        if value > 2 ** 64 / 2 - 1 or value < -2 ** 64 / 2:
        raise OverflowError("BSON can only handle up to 8-byte ints")
        if value > 2 ** 32 / 2 - 1 or value < -2 ** 32 / 2:
        return "\x12" + name + struct.pack("<q", value)
        return "\x10" + name + struct.pack("<i", value)

      This is a really ugly way and it does not allow to store long (>2**32) value, which was stored as zero and then $inc'ed.

        1. pymongo-bson-number.patch
          1 kB
          Alexey Gladkov

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            raorn Alexey I. Froloff
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: