Skip to content

Commit 1da969d

Browse files
mari6274odrotbohm
authored andcommitted
DATACMNS-1304 - PropertyPath now supports properties with all uppercase endings.
Original pull request: #289.
1 parent fc2135d commit 1da969d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @author Oliver Gierke
4343
* @author Christoph Strobl
4444
* @author Mark Paluch
45+
* @author Mariusz Mączkowski
4546
*/
4647
@EqualsAndHashCode
4748
public class PropertyPath implements Streamable<PropertyPath> {
@@ -401,7 +402,7 @@ private static PropertyPath create(String source, TypeInformation<?> type, Strin
401402
exception = e;
402403
}
403404

404-
Pattern pattern = Pattern.compile("\\p{Lu}+\\p{Ll}*$");
405+
Pattern pattern = Pattern.compile("\\p{Lu}\\p{Ll}*$");
405406
Matcher matcher = pattern.matcher(source);
406407

407408
if (matcher.find() && matcher.start() != 0) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* @author Christoph Strobl
4545
* @author Mark Paluch
4646
* @author Michael Cramer
47+
* @author Mariusz Mączkowski
4748
*/
4849
public class PartTreeUnitTests {
4950

@@ -600,6 +601,16 @@ public void emptyTreeDoesNotContainParts() {
600601
assertThat(tree.hasPredicate()).isFalse();
601602
}
602603

604+
@Test // DATACMNS-1304
605+
public void resolvesPropertyPathWithSingleUppercaseLetterPropertyEnding() {
606+
assertThat(new PartTree("findByCategoryBId", Product.class)).isNotNull();
607+
}
608+
609+
@Test // DATACMNS-1304
610+
public void resolvesPropertyPathWithUppercaseLettersPropertyEnding() {
611+
assertThat(new PartTree("findByCategoryABId", Product.class)).isNotNull();
612+
}
613+
603614
private static void assertLimiting(String methodName, Class<?> entityType, boolean limiting, Integer maxResults) {
604615
assertLimiting(methodName, entityType, limiting, maxResults, false);
605616
}
@@ -723,6 +734,10 @@ interface Product {
723734
Anders getAnders(); // constains And keyword
724735

725736
Category getCategory();
737+
738+
Category getCategoryB(); // contains single uppercase letter at the end
739+
740+
Category getCategoryAB(); // contains uppercase letters at the end
726741
}
727742

728743
interface Category {

0 commit comments

Comments
 (0)