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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.10.1
    • Component/s: None
    • Labels:
      None
    • # Replies:
      3
    • Last comment by Customer:
      true

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  7 years, 42 weeks, 4 days ago
                  Date of 1st Reply: