From f7eb58341e0fd33414818943007cf8e934798d71 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Fri, 28 Apr 2023 11:07:49 +0200 Subject: [PATCH] Fix in-array predicate rendering for cockroachdb --- .../dialect/CockroachLegacySqlAstTranslator.java | 9 +++++++++ .../org/hibernate/dialect/CockroachSqlAstTranslator.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacySqlAstTranslator.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacySqlAstTranslator.java index adee88464b..84048cac6a 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacySqlAstTranslator.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacySqlAstTranslator.java @@ -15,6 +15,7 @@ import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.Literal; import org.hibernate.sql.ast.tree.expression.Summarization; import org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate; +import org.hibernate.sql.ast.tree.predicate.InArrayPredicate; import org.hibernate.sql.ast.tree.predicate.LikePredicate; import org.hibernate.sql.ast.tree.select.QueryGroup; import org.hibernate.sql.ast.tree.select.QueryPart; @@ -183,4 +184,12 @@ public class CockroachLegacySqlAstTranslator extends Ab protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() { return false; } + + @Override + public void visitInArrayPredicate(InArrayPredicate inArrayPredicate) { + inArrayPredicate.getTestExpression().accept( this ); + appendSql( " = ANY(" ); + inArrayPredicate.getArrayParameter().accept( this ); + appendSql( ')' ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/CockroachSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/dialect/CockroachSqlAstTranslator.java index c02756f6bf..532550b6cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/CockroachSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/CockroachSqlAstTranslator.java @@ -15,6 +15,7 @@ import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.Literal; import org.hibernate.sql.ast.tree.expression.Summarization; import org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate; +import org.hibernate.sql.ast.tree.predicate.InArrayPredicate; import org.hibernate.sql.ast.tree.predicate.LikePredicate; import org.hibernate.sql.ast.tree.select.QueryGroup; import org.hibernate.sql.ast.tree.select.QueryPart; @@ -155,4 +156,12 @@ public class CockroachSqlAstTranslator extends Abstract protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() { return false; } + + @Override + public void visitInArrayPredicate(InArrayPredicate inArrayPredicate) { + inArrayPredicate.getTestExpression().accept( this ); + appendSql( " = ANY(" ); + inArrayPredicate.getArrayParameter().accept( this ); + appendSql( ')' ); + } }