-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
use org.bson.conversions.Bson instead of org.bson.Document in PanacheMongoEntityBase #42658
Comments
/cc @FroMage (panache), @loicmathieu (mongodb,panache) |
This is totally legitimate and in fact under the cover we already use I remember already wanted to do this change but didn't as it's a huge change and I fear for backward compatibility (this is at least not binary compatible). |
Couldn't we keep both methods for a while? |
Yes, I'll have a look if there a not too many of them as the interface is already crowded. |
@gsmet keeping both method would have the same issue as Java always dispatch to the more precise type parameter so the old method will still be used by existing code using Moreover it would bring unnecessary burden to the user as the only way to force using the new methods instead of the old ones would be to cast! If I'm not wrong, here is what would happen. We have this existing method with a public static <T extends PanacheMongoEntityBase> PanacheQuery<T> find(Document query) {
} We would add this one and deprecate the old one: public static <T extends PanacheMongoEntityBase> PanacheQuery<T> find(Bson query) {
} So now you would be able to use a MyEntity.find(Filters.lte("activatedUntil", activatedUntil)) But existing code will still use he old method except if you cast: MyEntity.find(new Document().append("category", "category1")); // still use the find(Document query) method
MyEntity.find((Bson) new Document().append("category", "category1")); // cast to force using the ind(Bson query) method I'll try to move from Document to Bson and see how it works. |
But my understanding is that using the Could you clarify why using the old method when you have a That being said, we don't have a guarantee of binary compatibility with Quarkus so we can adjust it if it's too cumbersome. We just try to not break people if we can avoid it. |
It's just that creating new method in Panache has a hight cost as there is already a lot of them (and each implies code generation under the cover) so if we don't need to maintain binary compatibility I would prefer to replace the actual one instead of duplicating them. We're talking about 10 methods in an already crowded class or interface. I'll open a PR to see what it is about, if you think it's better to duplicate I can do it. |
See candidate PR: #42726 |
Thanks for adding this change so quickly, didn't expect that,thank you although I didn't go though the code yet 😁👍 |
Description
usually one writes filters in like so
for such simple cases this is appropriate:
however if i want any more complex stuff i can not put
org.bson.conversions.Bson
into the find function since its only accepting documents, andorg.bson.conversions.Bson
dosen't implement that it is rather the opposite.i think this is an unnecessary barrier because i don't see a reason why one should not be able to call
thank you
Implementation ideas
change occurrences of
org.bson.Document
toorg.bson.conversions.Bson
The text was updated successfully, but these errors were encountered: