Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sikandar
Copy link

@sikandar sikandar commented Jul 1, 2024

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).

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"]}}
@pivotal-cla
Copy link

@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.

@pivotal-cla
Copy link

@sikandar Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 1, 2024
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).
@christophstrobl
Copy link
Member

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 Collection.

As {"$in" : [["n1", "n2"]]} matches differently from {"$in" : ["n1", "n2"]} I think revisiting the arrangement makes sense.

@christophstrobl christophstrobl added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 2, 2024
@sikandar
Copy link
Author

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 Collection.

As {"$in" : [["n1", "n2"]]} matches differently from {"$in" : ["n1", "n2"]} I think revisiting the arrangement makes sense.

This solution will be able to work with Variable Arguments

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants