Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1971

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.1.0
    • Affects Version/s: 3.0.4
    • Component/s: None
    • Labels:
      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@mongodb.com Ross Lawley
            Reporter:
            gordonsyme Gordon Syme
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: