File tree 2 files changed +13
-1
lines changed
main/java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ public abstract class QueryUtils {
138
138
static {
139
139
140
140
StringBuilder builder = new StringBuilder ();
141
- builder .append ("(?<=from )" ); // from as starting delimiter
141
+ builder .append ("(?<=\\ bfrom )" ); // from as starting delimiter
142
142
builder .append ("(?:\\ s)+" ); // at least one space separating
143
143
builder .append (IDENTIFIER_GROUP ); // Entity name, can be qualified (any
144
144
builder .append ("(?:\\ sas)*" ); // exclude possible "as" keyword
Original file line number Diff line number Diff line change @@ -130,6 +130,18 @@ void detectsAliasCorrectly() throws Exception {
130
130
assertThat (detectAlias (
131
131
"(from Foo f max(f) ((((select * from Foo f2 (from Foo f3) max(*)) (from Foo f4)) max(f5)) (f6)) (from Foo f7))" ))
132
132
.isEqualTo ("f" );
133
+ assertThat (detectAlias (
134
+ "SELECT e FROM DbEvent e WHERE (CAST(:modifiedFrom AS date) IS NULL OR e.modificationDate >= :modifiedFrom)" ))
135
+ .isEqualTo ("e" );
136
+ assertThat (detectAlias ("from User u where (cast(:effective as date) is null) OR :effective >= u.createdAt" ))
137
+ .isEqualTo ("u" );
138
+ assertThat (detectAlias ("from User u where (cast(:effectiveDate as date) is null) OR :effectiveDate >= u.createdAt" ))
139
+ .isEqualTo ("u" );
140
+ assertThat (detectAlias ("from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt" ))
141
+ .isEqualTo ("u" );
142
+ assertThat (
143
+ detectAlias ("from User u where (cast(:e1f2f3ectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt" ))
144
+ .isEqualTo ("u" );
133
145
}
134
146
135
147
@ Test // GH-2260
You can’t perform that action at this time.
0 commit comments