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 {
138138 static {
139139
140140 StringBuilder builder = new StringBuilder ();
141- builder .append ("(?<=from )" ); // from as starting delimiter
141+ builder .append ("(?<=\\ bfrom )" ); // from as starting delimiter
142142 builder .append ("(?:\\ s)+" ); // at least one space separating
143143 builder .append (IDENTIFIER_GROUP ); // Entity name, can be qualified (any
144144 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 {
130130 assertThat (detectAlias (
131131 "(from Foo f max(f) ((((select * from Foo f2 (from Foo f3) max(*)) (from Foo f4)) max(f5)) (f6)) (from Foo f7))" ))
132132 .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" );
133145 }
134146
135147 @ Test // GH-2260
You can’t perform that action at this time.
0 commit comments