From 31bc67b8ec3be80c1aa596e36133f032ec546524 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 26 Jun 2023 09:24:36 +0200 Subject: [PATCH] Backoff JSqlParserQueryEnhancer if query type is not a supported query type. We now backoff from enhancing queries if the query type is not supported (e.g. TRUNCATE). Closes #3038 --- .../repository/query/JSqlParserQueryEnhancer.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java b/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java index cd9fc61d7..3e3de9097 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java @@ -96,7 +96,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer { } else if (statement instanceof Merge) { return ParsedType.MERGE; } else { - return ParsedType.SELECT; + return ParsedType.OTHER; } } catch (JSQLParserException e) { throw new IllegalArgumentException("The query you provided is not a valid SQL Query!", e); @@ -316,10 +316,10 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer { Select selectStatement = parseSelectStatement(query); /* - For all the other types ({@link ValuesStatement} and {@link SetOperationList}) it does not make sense to provide - alias since: - * ValuesStatement has no alias - * SetOperation can have multiple alias for each operation item + * For all the other types ({@link ValuesStatement} and {@link SetOperationList}) it does not make sense to provide + * alias since: + * ValuesStatement has no alias + * SetOperation can have multiple alias for each operation item */ if (!(selectStatement.getSelectBody() instanceof PlainSelect)) { return null; @@ -519,10 +519,11 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer { *
  • {@code ParsedType.SELECT}: means the top level statement is {@link Select}
  • *
  • {@code ParsedType.INSERT}: means the top level statement is {@link Insert}
  • *
  • {@code ParsedType.MERGE}: means the top level statement is {@link Merge}
  • + *
  • {@code ParsedType.OTHER}: means the top level statement is a different top-level type
  • * */ enum ParsedType { - DELETE, UPDATE, SELECT, INSERT, MERGE; + DELETE, UPDATE, SELECT, INSERT, MERGE, OTHER; } }