File tree 5 files changed +46
-0
lines changed
antlr4/org/springframework/data/jpa/repository/query
java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query
5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -685,18 +685,22 @@ subtype
685
685
686
686
collection_valued_field
687
687
: identification_variable
688
+ | reserved_word
688
689
;
689
690
690
691
single_valued_object_field
691
692
: identification_variable
693
+ | reserved_word
692
694
;
693
695
694
696
state_field
695
697
: identification_variable
698
+ | reserved_word
696
699
;
697
700
698
701
collection_value_field
699
702
: identification_variable
703
+ | reserved_word
700
704
;
701
705
702
706
entity_name
Original file line number Diff line number Diff line change @@ -2108,21 +2108,36 @@ public QueryTokenStream visitSubtype(JpqlParser.SubtypeContext ctx) {
2108
2108
2109
2109
@ Override
2110
2110
public QueryTokenStream visitCollection_valued_field (JpqlParser .Collection_valued_fieldContext ctx ) {
2111
+ if (ctx .reserved_word () != null ) {
2112
+ return visit (ctx .reserved_word ());
2113
+ }
2111
2114
return visit (ctx .identification_variable ());
2112
2115
}
2113
2116
2114
2117
@ Override
2115
2118
public QueryTokenStream visitSingle_valued_object_field (JpqlParser .Single_valued_object_fieldContext ctx ) {
2119
+
2120
+ if (ctx .reserved_word () != null ) {
2121
+ return visit (ctx .reserved_word ());
2122
+ }
2116
2123
return visit (ctx .identification_variable ());
2117
2124
}
2118
2125
2119
2126
@ Override
2120
2127
public QueryTokenStream visitState_field (JpqlParser .State_fieldContext ctx ) {
2128
+
2129
+ if (ctx .reserved_word () != null ) {
2130
+ return visit (ctx .reserved_word ());
2131
+ }
2121
2132
return visit (ctx .identification_variable ());
2122
2133
}
2123
2134
2124
2135
@ Override
2125
2136
public QueryTokenStream visitCollection_value_field (JpqlParser .Collection_value_fieldContext ctx ) {
2137
+
2138
+ if (ctx .reserved_word () != null ) {
2139
+ return visit (ctx .reserved_word ());
2140
+ }
2126
2141
return visit (ctx .identification_variable ());
2127
2142
}
2128
2143
Original file line number Diff line number Diff line change @@ -1040,4 +1040,13 @@ void lateralShouldBeAValidParameter() {
1040
1040
assertQuery ("select e from Employee e where e.lateral = :_lateral" );
1041
1041
assertQuery ("select te from TestEntity te where te.lateral = :lateral" );
1042
1042
}
1043
+
1044
+ @ Test
1045
+ void reservedWordsShouldWork () {
1046
+
1047
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1048
+ assertQuery ("select ie.object from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1049
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.object = :externalId" );
1050
+ assertQuery ("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP" );
1051
+ }
1043
1052
}
Original file line number Diff line number Diff line change @@ -1923,4 +1923,13 @@ void entityNameWithPackageContainingReservedWord(String reservedWord) {
1923
1923
String source = "select new com.company.%s.thing.stuff.ClassName(e.id) from Experience e" .formatted (reservedWord );
1924
1924
assertQuery (source );
1925
1925
}
1926
+
1927
+ @ Test
1928
+ void reservedWordsShouldWork () {
1929
+
1930
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1931
+ assertQuery ("select ie.object from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1932
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.object = :externalId" );
1933
+ assertQuery ("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP" );
1934
+ }
1926
1935
}
Original file line number Diff line number Diff line change @@ -1027,4 +1027,13 @@ void entityNameWithPackageContainingReservedWord(String reservedWord) {
1027
1027
assertQuery (source );
1028
1028
}
1029
1029
1030
+ @ Test
1031
+ void reservedWordsShouldWork () {
1032
+
1033
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1034
+ assertQuery ("select ie.object from ItemExample ie left join ie.object io where io.externalId = :externalId" );
1035
+ assertQuery ("select ie from ItemExample ie left join ie.object io where io.object = :externalId" );
1036
+ assertQuery ("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP" );
1037
+ }
1038
+
1030
1039
}
You can’t perform that action at this time.
0 commit comments