-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fixed the bug, a null able list does not work #4734
base: main
Are you sure you want to change the base?
Conversation
If there is a nullable list with values, the implementation should check it instead of wrapping the nullable list (even if it has values) into another newly created list by the Criteria class. if (!filter.ids.isNullOrEmpty()) criteria.and("id").`in`(filter.ids) -> {"id" : { "$in" : [["667e8b8af76f17213e4d4280"]]}} if (!filter.ids.isNullOrEmpty()) criteria.and("id").`in`(filter.ids!!) -> {"id" :{ "$in" : ["667e8b8af76f17213e4d4280"]}}
@sikandar Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@sikandar Thank you for signing the Contributor License Agreement! |
If there is a nullable list with values, the implementation should check it instead of wrapping the nullable list (even if it has values) into another newly created list by the Criteria class. Existing Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids) Output: {"id" : { "$in" : [["667e8b8af76f17213e4d4280"]]}} Wrong Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids!!) Required !! Output: {"id" :{ "$in" : ["667e8b8af76f17213e4d4280"]}} Correct After Fix Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids) With and Without !! Output: {"id" : { "$in" : ["667e8b8af76f17213e4d4280"]}} Correct
If there is a nullable list with values, the implementation should check it instead of wrapping the nullable list (even if it has values) into another newly created list by the Criteria class. Existing Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids) Output: {"id" : { "$in" : [["667e8b8af76f17213e4d4280"]]}} Wrong Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids!!) Required !! Output: {"id" :{ "$in" : ["667e8b8af76f17213e4d4280"]}} Correct After Fix Code: if (!filter.ids.isNullOrEmpty()) criteria.and("id").in(filter.ids) With and Without !! Output: {"id" : { "$in" : ["667e8b8af76f17213e4d4280"]}} Correct You have read the Spring Data contribution guidelines. You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes. You submit test cases (unit or integration tests) that back your changes. You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
Thank you for getting in touch. Please explain why you think this is necessary and provide throughout testcases for the proposed change since there's a method that accepts a As |
This solution will be able to work with Variable Arguments |
If there is a nullable list with values, the implementation should check it instead of wrapping the nullable list (even if it has values) into another newly created list by the Criteria class.
Existing
Code:
if (!filter.ids.isNullOrEmpty()) criteria.and("id").
in(filter.ids)
Output:
{"id" : { "$in" : [["667e8b8af76f17213e4d4280"]]}}
WrongCode:
if (!filter.ids.isNullOrEmpty()) criteria.and("id").
in(filter.ids!!)
Required !!Output:
{"id" :{ "$in" : ["667e8b8af76f17213e4d4280"]}}
CorrectAfter Fix
Code:
if (!filter.ids.isNullOrEmpty()) criteria.and("id").
in(filter.ids)
With and Without !!Output:
{"id" : { "$in" : ["667e8b8af76f17213e4d4280"]}}
Correct