Skip to content

Drop SpEL support in the query parsers. #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data JPA Parent</name>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-envers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-jpa-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>

<name>Spring Data JPA</name>
<description>Spring Data module for JPA repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-gh-2881-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ variable

parameter
: prefix=':' identifier
| prefix='?' (INTEGER_LITERAL | spelExpression)?
| prefix='?' INTEGER_LITERAL?
;

entityName
Expand All @@ -629,16 +629,8 @@ entityName

identifier
: reservedWord
| spelExpression
;

spelExpression
: prefix='#{#' identificationVariable ('.' identificationVariable)* '}' // #{#entityName}
| prefix='#{#[' INTEGER_LITERAL ']}' // #{[0]}
| prefix='#{' identificationVariable '(' ( stringLiteral | '[' INTEGER_LITERAL ']' )? ')}' // #{escape([0])} | #{escapeCharacter()}
;


character
: CHARACTER
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ identification_variable
| ORDER // Gap in the spec requires supporting 'Order' as an entity name
| COUNT // Gap in the spec requires supporting 'count' as a possible name
| KEY // Gap in the sepc requires supported 'key' as a possible name
| spel_expression // we use various SpEL expressions in our queries
;

constructor_name
Expand Down Expand Up @@ -704,12 +703,6 @@ function_name
: string_literal
;

spel_expression
: prefix='#{#' identification_variable ('.' identification_variable)* '}' // #{#entityName}
| prefix='#{#[' INTLITERAL ']}' // #{[0]}
| prefix='#{' identification_variable '(' ( string_literal | '[' INTLITERAL ']' )? ')}' // #{escape([0])} | #{escapeCharacter()}
;

character_valued_input_parameter
: CHARACTER
| input_parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2222,8 +2222,6 @@ public List<JpaQueryParsingToken> visitParameter(HqlParser.ParameterContext ctx)

if (ctx.INTEGER_LITERAL() != null) {
tokens.add(new JpaQueryParsingToken(ctx.INTEGER_LITERAL()));
} else if (ctx.spelExpression() != null) {
tokens.addAll(visit(ctx.spelExpression()));
}
}

Expand Down Expand Up @@ -2251,57 +2249,11 @@ public List<JpaQueryParsingToken> visitIdentifier(HqlParser.IdentifierContext ct

if (ctx.reservedWord() != null) {
return visit(ctx.reservedWord());
} else if (ctx.spelExpression() != null) {
return visit(ctx.spelExpression());
} else {
return List.of();
}
}

@Override
public List<JpaQueryParsingToken> visitSpelExpression(HqlParser.SpelExpressionContext ctx) {

List<JpaQueryParsingToken> tokens = new ArrayList<>();

if (ctx.prefix.equals("#{#")) { // #{#entityName}

tokens.add(new JpaQueryParsingToken(ctx.prefix));

ctx.identificationVariable().forEach(identificationVariableContext -> {
tokens.addAll(visit(identificationVariableContext));
tokens.add(TOKEN_DOT);
});
CLIP(tokens);

tokens.add(TOKEN_CLOSE_BRACE);

} else if (ctx.prefix.equals("#{#[")) { // #{[0]}

tokens.add(new JpaQueryParsingToken(ctx.prefix));
tokens.add(new JpaQueryParsingToken(ctx.INTEGER_LITERAL()));
tokens.add(TOKEN_CLOSE_SQUARE_BRACKET_BRACE);

} else if (ctx.prefix.equals("#{")) {// #{escape([0])} or #{escape('foo')}

tokens.add(new JpaQueryParsingToken(ctx.prefix));
tokens.addAll(visit(ctx.identificationVariable(0)));
tokens.add(TOKEN_OPEN_PAREN);

if (ctx.stringLiteral() != null) {
tokens.addAll(visit(ctx.stringLiteral()));
} else if (ctx.INTEGER_LITERAL() != null) {

tokens.add(TOKEN_OPEN_SQUARE_BRACKET);
tokens.add(new JpaQueryParsingToken(ctx.INTEGER_LITERAL()));
tokens.add(TOKEN_CLOSE_SQUARE_BRACKET);
}

tokens.add(TOKEN_CLOSE_PAREN_BRACE);
}

return tokens;
}

@Override
public List<JpaQueryParsingToken> visitCharacter(HqlParser.CharacterContext ctx) {
return List.of(new JpaQueryParsingToken(ctx.CHARACTER()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2124,8 +2124,6 @@ public List<JpaQueryParsingToken> visitIdentification_variable(JpqlParser.Identi
return List.of(new JpaQueryParsingToken(ctx.ORDER()));
} else if (ctx.KEY() != null) {
return List.of(new JpaQueryParsingToken(ctx.KEY()));
} else if (ctx.spel_expression() != null) {
return visit(ctx.spel_expression());
} else {
return List.of();
}
Expand Down Expand Up @@ -2322,48 +2320,6 @@ public List<JpaQueryParsingToken> visitFunction_name(JpqlParser.Function_nameCon
return visit(ctx.string_literal());
}

@Override
public List<JpaQueryParsingToken> visitSpel_expression(JpqlParser.Spel_expressionContext ctx) {

List<JpaQueryParsingToken> tokens = new ArrayList<>();

if (ctx.prefix.equals("#{#")) { // #{#entityName}

tokens.add(new JpaQueryParsingToken(ctx.prefix));
ctx.identification_variable().forEach(identificationVariableContext -> {
tokens.addAll(visit(identificationVariableContext));
tokens.add(TOKEN_DOT);
});
CLIP(tokens);
tokens.add(TOKEN_CLOSE_BRACE);

} else if (ctx.prefix.equals("#{#[")) { // #{[0]}

tokens.add(new JpaQueryParsingToken(ctx.prefix));
tokens.add(new JpaQueryParsingToken(ctx.INTLITERAL()));
tokens.add(TOKEN_CLOSE_SQUARE_BRACKET_BRACE);

} else if (ctx.prefix.equals("#{")) {// #{escape([0])} or #{escape('foo')}

tokens.add(new JpaQueryParsingToken(ctx.prefix));
tokens.addAll(visit(ctx.identification_variable(0)));
tokens.add(TOKEN_OPEN_PAREN);

if (ctx.string_literal() != null) {
tokens.addAll(visit(ctx.string_literal()));
} else if (ctx.INTLITERAL() != null) {

tokens.add(TOKEN_OPEN_SQUARE_BRACKET);
tokens.add(new JpaQueryParsingToken(ctx.INTLITERAL()));
tokens.add(TOKEN_CLOSE_SQUARE_BRACKET);
}

tokens.add(TOKEN_CLOSE_PAREN_BRACE);
}

return tokens;
}

@Override
public List<JpaQueryParsingToken> visitCharacter_valued_input_parameter(
JpqlParser.Character_valued_input_parameterContext ctx) {
Expand Down