Skip to content

Conversation

peteraisher
Copy link
Contributor

Summary

This PR updates the handling of Specification.unrestricted() (and other specifications whose toPredicate(..) method returns null) in Specification.not(..) to ensure consistent handling across all logical operations:

unrestricted().or(other)       // equivalent to other
not(unrestricted()).or(other)  // equivalent to other               *changed*
unrestricted().and(other)      // equivalent to other
not(unrestricted()).and(other) // equivalent to other               *changed*
not(unrestricted())            // equivalent to unrestricted()      *changed*

Changes

  • Updated tests to verify that not(unrestricted()).toPredicate(..) returns null and that no CriteriaBuilder methods are called.
  • Updated implementation accordingly.
  • Updated documentation to better explain the semantics of a specification whose toPredicate(..) method returns null, in particular the static unrestricted() factory method.
  • Mirrored changes across Specification, DeleteSpecification, PredicateSpecification, and UpdateSpecification classes.

PR Checklist

  • I have read the Spring Data contribution guidelines.
  • I used the code formatters provided here and have them applied to my changes.
  • I am submitting updated test cases that back my changes.
  • I added myself as author in the headers of the classes I touched, and amended the date range in the Apache license headers where needed.

Closes #4023

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2025
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 26, 2025
@mp911de mp911de self-assigned this Sep 26, 2025
mp911de pushed a commit that referenced this pull request Sep 26, 2025
Closes #4203
Original pull request: #4024

Signed-off-by: Peter Aisher <[email protected]>
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4203
Original pull request: #4024
mp911de pushed a commit that referenced this pull request Sep 26, 2025
Closes #4203
Original pull request: #4024

Signed-off-by: Peter Aisher <[email protected]>
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4203
Original pull request: #4024
mp911de pushed a commit that referenced this pull request Sep 26, 2025
Closes #4203
Original pull request: #4024

Signed-off-by: Peter Aisher <[email protected]>
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4203
Original pull request: #4024
mp911de pushed a commit that referenced this pull request Sep 26, 2025
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4023
Original pull request: #4024
mp911de pushed a commit that referenced this pull request Sep 26, 2025
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4023
Original pull request: #4024
mp911de pushed a commit that referenced this pull request Sep 26, 2025
mp911de added a commit that referenced this pull request Sep 26, 2025
Refine Javadoc.

See #4023
Original pull request: #4024
@mp911de
Copy link
Member

mp911de commented Sep 26, 2025

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this Sep 26, 2025
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.

Inconsistency in Specification.unrestricted() semantics
3 participants