Browse Source

DATACMNS-1304 - PropertyPath now supports properties with all uppercase endings.

Original pull request: #289.
pull/289/merge
Mariusz Mączkowski 8 years ago committed by Oliver Gierke
parent
commit
1da969db0a
No known key found for this signature in database
GPG Key ID: 6E42B5787543F690
  1. 3
      src/main/java/org/springframework/data/mapping/PropertyPath.java
  2. 15
      src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java

3
src/main/java/org/springframework/data/mapping/PropertyPath.java

@ -42,6 +42,7 @@ import org.springframework.util.StringUtils; @@ -42,6 +42,7 @@ import org.springframework.util.StringUtils;
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
* @author Mariusz Mączkowski
*/
@EqualsAndHashCode
public class PropertyPath implements Streamable<PropertyPath> {
@ -401,7 +402,7 @@ public class PropertyPath implements Streamable<PropertyPath> { @@ -401,7 +402,7 @@ public class PropertyPath implements Streamable<PropertyPath> {
exception = e;
}
Pattern pattern = Pattern.compile("\\p{Lu}+\\p{Ll}*$");
Pattern pattern = Pattern.compile("\\p{Lu}\\p{Ll}*$");
Matcher matcher = pattern.matcher(source);
if (matcher.find() && matcher.start() != 0) {

15
src/test/java/org/springframework/data/repository/query/parser/PartTreeUnitTests.java

@ -44,6 +44,7 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart; @@ -44,6 +44,7 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
* @author Christoph Strobl
* @author Mark Paluch
* @author Michael Cramer
* @author Mariusz Mączkowski
*/
public class PartTreeUnitTests {
@ -600,6 +601,16 @@ public class PartTreeUnitTests { @@ -600,6 +601,16 @@ public class PartTreeUnitTests {
assertThat(tree.hasPredicate()).isFalse();
}
@Test // DATACMNS-1304
public void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding() {
assertThat(new PartTree("findByCategoryBId", Product.class)).isNotNull();
}
@Test // DATACMNS-1304
public void resolvesPropertyPathWithUppercaseLettersPropertyEnding() {
assertThat(new PartTree("findByCategoryABId", Product.class)).isNotNull();
}
private static void assertLimiting(String methodName, Class<?> entityType, boolean limiting, Integer maxResults) {
assertLimiting(methodName, entityType, limiting, maxResults, false);
}
@ -723,6 +734,10 @@ public class PartTreeUnitTests { @@ -723,6 +734,10 @@ public class PartTreeUnitTests {
Anders getAnders(); // constains And keyword
Category getCategory();
Category getCategoryB(); // contains single uppercase letter at the end
Category getCategoryAB(); // contains uppercase letters at the end
}
interface Category {

Loading…
Cancel
Save