-
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
MongoDB panache generates invalid update documents when updating a list or array with HQL #27326
Comments
/cc @FroMage, @evanchooly, @loicmathieu |
@languitar this indeed looks like a bug, I'll have a look. |
I just check the code and I'm not sure it's possible to update it. The code is shared between query document and update document. For query document, if it's a native query the user must include the
If I change this it may break existing code, at least for the native query, we can deal with the PanacheQL change on our side. I agree that this is unfortunate for update document, maybe different mapping translation rules should be applied. For your example, a query like this may work: As you notted, Map is currently not managed by our translation rules. |
Just checked and unfortunatly
I keep it open for a while, maybe i'll come up with a solution but for now there is no other way than using a native query as to fix this we will need to break existing code that use collection parameters in a native query. |
Sounds like a different transformation is needed for the update part to get this working. If that is not a viable option, at least a more informative error message would be nice instead of a BSON parsing exception. |
While this is a breaking change for native, I think we shouldn't have to add the [] when dealing with lists: that's not something you do in HQL, it shouldn't be something you have to do in native. Fixes quarkusio#27326
While this is a breaking change for native, I think we shouldn't have to add the [] when dealing with lists: that's not something you do in HQL, it shouldn't be something you have to do in native. Fixes quarkusio#27326
While this is a breaking change for native, I think we shouldn't have to add the [] when dealing with lists: that's not something you do in HQL, it shouldn't be something you have to do in native. Fixes quarkusio#27326
Describe the bug
When using the
update
method on a MongoDB panache entity with an HQL-like update description and a list or array parameter, the update fails, because an invalid update document is created.Expected behavior
Arrays or lists of primitives can be updated using HQL or a proper exception is thrown in case this is not supported.
Actual behavior
The update fails with
How to Reproduce?
Reproduder: https://github.com/languitar/quarkus-mongodb-panache-update-list-reproducer
curl -v http://localhost:8080/hello
Output of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.11.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
Currently, if the list with the new values to set in the update operation contains only one element, the data in the database will be switched from an array to string, consequently breaking any further reads using the POJO.
All this happens, because
PanacheQlQueryBinder
expands a list into multiple comma-separated tokens, omitting the surrounding array square brackets:results in:
The text was updated successfully, but these errors were encountered: