You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider #2080, which added support for the OrderBy keyword in dynamic queries. For example, your repository can call findAllOrderByBar() and it will return all elements sorted by the bar field.
Before this change, if your repository had findAllOrderByBar(), the method gets called and nothing is sorted. This is definitely a surprise for the user. Similarly, if the user tries to use other keywords they might expect (perhaps findByAgeLessThan(int age), Spring Redis will return data that doesn't match the user's expectations.
I would like to suggest that for situations like this with unsupported keywords, an UnsupportedOperationException is thrown (or another exception if it is more appropriate). Perhaps more generally if there is anything about the method name that isn't understood (like if field bar doesn't exist or isn't @Indexed), an exception could be thrown as well.
This would save developers time debugging code that appears to be valid, but will never work.
Current Behavior
Calling a dynamic query with an unsupported keyword does not return data that the developer expects.
Desired behavior
Calling a dynamic query with an unsupported keyword should throw an UnsupportedOperationException or a similarly appropriate exception.
The text was updated successfully, but these errors were encountered:
The relationship between @Indexed and a derived query using such property is a bit more tricky as indexing can happen also outside of Spring Data Redis so we do not have a way to know about that. Generally, starting with tests to ensure proper usage is a good approach.
So the issue in #2080 was that the OrderBy keyword was supported, but not working properly?
In that case, I may have overgeneralized the situation. If there are technical hurdles with @Indexed, then I do not think there is anything actionable to do with this ticket.
Consider #2080, which added support for the
OrderBy
keyword in dynamic queries. For example, your repository can callfindAllOrderByBar()
and it will return all elements sorted by thebar
field.Before this change, if your repository had
findAllOrderByBar()
, the method gets called and nothing is sorted. This is definitely a surprise for the user. Similarly, if the user tries to use other keywords they might expect (perhapsfindByAgeLessThan(int age)
, Spring Redis will return data that doesn't match the user's expectations.I would like to suggest that for situations like this with unsupported keywords, an
UnsupportedOperationException
is thrown (or another exception if it is more appropriate). Perhaps more generally if there is anything about the method name that isn't understood (like if fieldbar
doesn't exist or isn't@Indexed
), an exception could be thrown as well.This would save developers time debugging code that appears to be valid, but will never work.
Current Behavior
Calling a dynamic query with an unsupported keyword does not return data that the developer expects.
Desired behavior
Calling a dynamic query with an unsupported keyword should throw an UnsupportedOperationException or a similarly appropriate exception.
The text was updated successfully, but these errors were encountered: