File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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 @@ -128,6 +128,18 @@ void detectsAliasCorrectly() {
128
128
assertThat (detectAlias (
129
129
"(from Foo f max(f) ((((select * from Foo f2 (from Foo f3) max(*)) (from Foo f4)) max(f5)) (f6)) (from Foo f7))" ))
130
130
.isEqualTo ("f" );
131
+ assertThat (detectAlias (
132
+ "SELECT e FROM DbEvent e WHERE (CAST(:modifiedFrom AS date) IS NULL OR e.modificationDate >= :modifiedFrom)" ))
133
+ .isEqualTo ("e" );
134
+ assertThat (detectAlias ("from User u where (cast(:effective as date) is null) OR :effective >= u.createdAt" ))
135
+ .isEqualTo ("u" );
136
+ assertThat (detectAlias ("from User u where (cast(:effectiveDate as date) is null) OR :effectiveDate >= u.createdAt" ))
137
+ .isEqualTo ("u" );
138
+ assertThat (detectAlias ("from User u where (cast(:effectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt" ))
139
+ .isEqualTo ("u" );
140
+ assertThat (
141
+ detectAlias ("from User u where (cast(:e1f2f3ectiveFrom as date) is null) OR :effectiveFrom >= u.createdAt" ))
142
+ .isEqualTo ("u" );
131
143
}
132
144
133
145
@ Test // GH-2260
You can’t perform that action at this time.
0 commit comments