Skip to content

Conversation

@backend-choijunhyeong
Copy link

Add support for IsEmpty and IsNotEmpty repository query keywords in derived queries.

Why

The documentation lists IsEmpty as a supported keyword, but it throws
"Unsupported keyword" exception when used.

Changes

  • Add IS_EMPTY and IS_NOT_EMPTY case handling in MongoQueryCreator.from()
  • Add createIsEmptyCriteria() and createIsNotEmptyCriteria() methods
  • String properties: { field: { $eq: "" } } / { field: { $ne: "" } }
  • Collection properties: { field: { $size: 0 } } / { field: { $not: { $size: 0 } } }

Resolves #4606

Add IS_EMPTY and IS_NOT_EMPTY case handling to MongoQueryCreator.
For String properties, compare with empty string using $eq/$ne.
For Collection properties, use $size operator.

Signed-off-by: backend-choijunhyeong <ajfeh22@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 18, 2026
@backend-choijunhyeong
Copy link
Author

backend-choijunhyeong commented Jan 18, 2026

I'd like to clarify the expected behavior regarding null values.

Current implementation

  • IsEmpty: matches only "" (empty string) or size: 0 (empty collection)
  • IsNotEmpty: matches anything that is not "" or size: 0

This means null values are NOT considered "empty".

Question
Should IsEmpty also match null values?
For example: findByFirstNameIsEmpty -> should it return documents where firstName is null?

Options

  1. Current: null is NOT considered empty (strict interpretation)
  2. Alternative: null OR "" is considered empty (lenient interpretation)

I can adjust the implementation based on the team's preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repository query keyword IS_EMPTY not supported

2 participants