-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 3.0.4
-
Component/s: 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.