System-generated index names assume asc/desc is specified with an Int32

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 3.1.0
    • Affects Version/s: 3.0.4
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      com.mongodb.operations.IndexHelper#generateIndexName assumes that the ascending/descending specifier for a key is either a BsonInt32 or a String.

      In the case of Clojure (at least), integer literals default to Long rather than Integer. The translation from a DBObject to a BsonDocument converts these longs to BsonInt64 types.

      This causes system generated index names to elide the ascending/descending information leading to index name collisions.

      Not a blocker, the obvious workaround is to ensure ascending/descending specifiers are Integers.

      I've attached a patch that uses BsonNumber to avoid this issue and confirmed it works when invoked from Clojure. Obviously I've got very limited context into the development of Mongo's Java driver so this probably isn't the right approach, but does illustrate the issue.

              Assignee:
              Ross Lawley
              Reporter:
              Gordon Syme
              None
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: