-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@IndexOptions not defaulting properly like deprecated @Index when using ensureIndexes(Class<T> clazz, boolean background) if background is true #791
Comments
It gets extracted out in Can you confirm me we're talking about the same thing here? It looks like there's no issue here. |
In my code, I did not specify the background value to true in the IndexOption annotation. Thus, in extractOptions, "background" will not be set in DBObject. When calling ensureIndexes with background == true flag, this is not taken into consideration on line 470 like it does on line 478 (deprecated interface). In other words, parameter background is totally ignored on line 470. |
Did you look at the link above? That's what this line check: putIfTrue(opts, "background", options.background()); |
The best way to explain the issue is to use a unit test (you need to modify the unit test the way you can grab mongo and datastore instances): public class MongoDbContainerTest ...
} Here's the output: IndexOptionColl index after drop [] As you can see, the deprecated usage of Index generates a "background": true. Whereas the IndexOptions does not. |
oooooh. I get it. Ironically, I'm working on that code now and completely glossed over the method parameter. I get what the issue is now. Thanks. |
This should cover this issue: https://github.com/mongodb/morphia/blob/master/morphia/src/test/java/org/mongodb/morphia/indexes/TestIndexes.java#L37-37. Do you see anything I missed? I think I have those holes plugged now. |
Perfect. I spaced out and forgot to write the actual assert! On Mon, Jul 6, 2015 at 1:27 PM, Justin Lee [email protected] wrote:
|
Version 0.111
I migrated to the new IndexOptions but noticed that my indexes were not being created in background when using IndexOptions in conjunction with ensureClasses(classz, background) where background is true:
It appears that the background boolean is not taken into account.
See org.mongodb.morphia.DatastoreImpl#processClassAnnotations, specifically line 470.
ensureIndex(mc, dbColl, index.fields(), index.options());
background value is being ignored (i.e not used).
Everywhere else in the code use the following convention
index.background() ? index.background() : background
The text was updated successfully, but these errors were encountered: