Skip to content

Commit 5085190

Browse files
committed
HHH-19768 Prefer values list rendering to emulate in-list tuples over select unions
1 parent e30e7c6 commit 5085190

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7753,7 +7753,24 @@ public void visitInListPredicate(InListPredicate inListPredicate) {
77537753
}
77547754
else if ( !supportsRowValueConstructorSyntaxInInList() ) {
77557755
// Some DBs like Oracle support tuples only for the IN subquery predicate
7756-
if ( supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsUnionAll() ) {
7756+
if ( supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsValuesList() ) {
7757+
inListPredicate.getTestExpression().accept( this );
7758+
if ( inListPredicate.isNegated() ) {
7759+
appendSql( " not" );
7760+
}
7761+
appendSql( " in (select * from (values" );
7762+
char separator = ' ';
7763+
for ( Expression expression : listExpressions ) {
7764+
appendSql( separator );
7765+
appendSql( OPEN_PARENTHESIS );
7766+
renderCommaSeparated( SqlTupleContainer.getSqlTuple( expression ).getExpressions() );
7767+
appendSql( CLOSE_PARENTHESIS );
7768+
separator = ',';
7769+
}
7770+
appendSql( CLOSE_PARENTHESIS );
7771+
appendSql( CLOSE_PARENTHESIS );
7772+
}
7773+
else if ( supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsUnionAll() ) {
77577774
inListPredicate.getTestExpression().accept( this );
77587775
if ( inListPredicate.isNegated() ) {
77597776
appendSql( " not" );

0 commit comments

Comments
 (0)