spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Fixed the bug, a null able list does not work

Open sikandar opened this issue 1 year ago • 4 comments

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

  • [x] You have read the Spring Data contribution guidelines.
  • [x] You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • [x] You submit test cases (unit or integration tests) that back your changes.
  • [x] 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).

sikandar avatar Jul 01 '24 14:07 sikandar