Fix in-array predicate rendering for cockroachdb

This commit is contained in:
Marco Belladelli 2023-04-28 11:07:49 +02:00
parent 203f28e14c
commit f7eb58341e
2 changed files with 18 additions and 0 deletions

View File

@ -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.Literal;
import org.hibernate.sql.ast.tree.expression.Summarization; import org.hibernate.sql.ast.tree.expression.Summarization;
import org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate; 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.predicate.LikePredicate;
import org.hibernate.sql.ast.tree.select.QueryGroup; import org.hibernate.sql.ast.tree.select.QueryGroup;
import org.hibernate.sql.ast.tree.select.QueryPart; import org.hibernate.sql.ast.tree.select.QueryPart;
@ -183,4 +184,12 @@ public class CockroachLegacySqlAstTranslator<T extends JdbcOperation> extends Ab
protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() { protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false; return false;
} }
@Override
public void visitInArrayPredicate(InArrayPredicate inArrayPredicate) {
inArrayPredicate.getTestExpression().accept( this );
appendSql( " = ANY(" );
inArrayPredicate.getArrayParameter().accept( this );
appendSql( ')' );
}
} }

View File

@ -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.Literal;
import org.hibernate.sql.ast.tree.expression.Summarization; import org.hibernate.sql.ast.tree.expression.Summarization;
import org.hibernate.sql.ast.tree.predicate.BooleanExpressionPredicate; 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.predicate.LikePredicate;
import org.hibernate.sql.ast.tree.select.QueryGroup; import org.hibernate.sql.ast.tree.select.QueryGroup;
import org.hibernate.sql.ast.tree.select.QueryPart; import org.hibernate.sql.ast.tree.select.QueryPart;
@ -155,4 +156,12 @@ public class CockroachSqlAstTranslator<T extends JdbcOperation> extends Abstract
protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() { protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
return false; return false;
} }
@Override
public void visitInArrayPredicate(InArrayPredicate inArrayPredicate) {
inArrayPredicate.getTestExpression().accept( this );
appendSql( " = ANY(" );
inArrayPredicate.getArrayParameter().accept( this );
appendSql( ')' );
}
} }