[JAVA-2124] Regression in DBCollection for retrieving Index information Created: 26/Feb/16 Updated: 11/Sep/19 Resolved: 15/Sep/16 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 3.2.2 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Brandon Vulaj [X] | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Most of the information is here: http://stackoverflow.com/questions/35659940/mongo-java-client-dbcollection-doesnt-return-whether-an-index-is-sparse-or-no But I'll also paste below.. After recently upgrading the Java Mongo Driver from 2.6 to 3.2, I've noticed that I can no longer see if an index is sparse or not in DBCollection. On top of that, I don't think it's even creating sparse indexes. For example:
Previously to upgrading, the following test has passed:
However, now the `sparse` field doesn't exist on the Index nor the returned JSON, at least as far as I can see in the Java driver. How can I verify if an index is `sparse` now, using DBCollection? This test is running against a 2.6 embedded MongoDB. I'll note that I updated my test, and my test only, to use the newer classes (MongoCollection) to create and retrieve indexes, and it seems to work. So, I have to assume that this is a regression in the DBCollection classes. |
| Comments |
| Comment by Jeffrey Yemin [ 01/Mar/16 ] | |||||||||||||||||||||||||||
|
Looking at the 3.x driver code, I can confirm what you're seeing. While it is a behavioral change in the driver, in practice the index will continue to function correctly, since false is the default value for sparse. But you'll have to modify the assertion to make it pass. Something like: assertTrue(!mongoIndex.containsField("sparse") || !mongoIndex.get("sparse")). | |||||||||||||||||||||||||||
| Comment by Brandon Vulaj [X] [ 29/Feb/16 ] | |||||||||||||||||||||||||||
|
Hi Jeff, What we saw before was `"sparse" : false` existing when it was explicitly set to false. Rather than not seeing a `sparse` field at all. See below:
Can you confirm that? Mongo server version is 2.6.8. | |||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 27/Feb/16 ] | |||||||||||||||||||||||||||
|
I ran a slightly modified version of your code against a 3.2 server, using the 3.2.2 driver:
and the output is:
Couple of questions:
|