Skip to content

DATACMNS-1007 - Is empty is not empty #203

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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/asciidoc/repository-query-keywords-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The following table lists the keywords generally supported by the Spring Data re
|`GREATER_THAN_EQUALS`|`GreaterThanEqual`, `IsGreaterThanEqual`
|`IN`|`In`, `IsIn`
|`IS`|`Is`, `Equals`, (or no keyword)
|`IS_EMPTY`|`IsEmpty`, `Empty`
|`IS_NOT_EMPTY`|`IsNotEmpty`, `NotEmpty`
|`IS_NOT_NULL`|`NotNull`, `IsNotNull`
|`IS_NULL`|`Null`, `IsNull`
|`LESS_THAN`|`LessThan`, `IsLessThan`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @author Oliver Gierke
* @author Martin Baumgartner
* @author Michael Cramer
*/
public class Part {

Expand Down Expand Up @@ -188,13 +189,15 @@ public static enum Type {
"IsNotContaining", "NotContaining", "NotContains"), CONTAINING("IsContaining", "Containing", "Contains"), NOT_IN(
"IsNotIn", "NotIn"), IN("IsIn", "In"), NEAR("IsNear", "Near"), WITHIN("IsWithin", "Within"), REGEX(
"MatchesRegex", "Matches", "Regex"), EXISTS(0, "Exists"), TRUE(0, "IsTrue", "True"), FALSE(0, "IsFalse",
"False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals");
"False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals"), IS_NOT_EMPTY(0, "IsNotEmpty",
"NotEmpty"), IS_EMPTY(0, "IsEmpty", "Empty");

// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL,
GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, NOT_CONTAINING,
CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
GREATER_THAN, GREATER_THAN_EQUAL, BEFORE, AFTER, NOT_LIKE, LIKE, STARTING_WITH, ENDING_WITH, IS_NOT_EMPTY,
IS_EMPTY, NOT_CONTAINING, CONTAINING, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE,
NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);

public static final Collection<String> ALL_KEYWORDS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @author Martin Baumgartner
* @author Christoph Strobl
* @author Mark Paluch
* @author Michael Cramer
*/
public class PartTreeUnitTests {

Expand Down Expand Up @@ -221,6 +222,16 @@ public void returnsAllPartsOfType() {
assertThat(parts, is(hasSize(1)));
}

@Test // DATACMNS-1007
public void parsesEmptyKeywordCorrectly() {
assertType(asList("friendsIsEmpty", "friendsEmpty"), IS_EMPTY, "friends", 0, false);
}

@Test // DATACMNS-1007
public void parsesNotEmptyKeywordCorrectly() {
assertType(asList("friendsIsNotEmpty", "friendsNotEmpty"), IS_NOT_EMPTY, "friends", 0, false);
}

@Test // DATACMNS-94
public void parsesExistsKeywordCorrectly() {
assertType(asList("lastnameExists"), EXISTS, "lastname", 0, false);
Expand Down Expand Up @@ -651,6 +662,7 @@ class User {
double[] location;
boolean active;
Date birthday;
List<User> friends;
}

class Organization {
Expand Down