Skip to content

Fix NPE in QueryMapper when trying to apply target type on null value. #3643

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

Closed
wants to merge 3 commits into from

Conversation

christophstrobl
Copy link
Member

This PR fixes a NPE when a Query does a null value equality comparison on a field that has a custom target type defined.

@Field(targetType = FieldType.OBJECT_ID) 
String parentId;

// ...

Query q = query(where("parentId").is(null));
template.find(q, ...

Further more we introduced additional methods (isNull(), isNullValue()) on Criteria that simplify query creation for null or missing fields.

Closes: #3633

@mp911de mp911de added the type: bug A general bug label Jun 9, 2021
@mp911de mp911de added this to the 3.1.10 (2020.0.10) milestone Jun 9, 2021
mp911de pushed a commit that referenced this pull request Jun 9, 2021
mp911de added a commit that referenced this pull request Jun 9, 2021
Add nullability annotation. Return early on null value conversion.

See #3633
Original pull request: #3643.
mp911de pushed a commit that referenced this pull request Jun 9, 2021
mp911de pushed a commit that referenced this pull request Jun 9, 2021
mp911de added a commit that referenced this pull request Jun 9, 2021
Add nullability annotation. Return early on null value conversion.

See #3633
Original pull request: #3643.
mp911de pushed a commit that referenced this pull request Jun 9, 2021
mp911de added a commit that referenced this pull request Jun 9, 2021
Add nullability annotation. Return early on null value conversion.

See #3633
Original pull request: #3643.
@mp911de
Copy link
Member

mp911de commented Jun 9, 2021

That's polished, merged and backported now.

@mp911de mp911de closed this Jun 9, 2021
@mp911de mp911de deleted the issue/3633 branch June 9, 2021 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE in QueryMapper when use Query with null as value
2 participants