Skip to content

Commit 8ddcf7f

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

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
@@ -7756,7 +7756,24 @@ public void visitInListPredicate(InListPredicate inListPredicate) {
77567756
}
77577757
else if ( !dialect.supportsRowValueConstructorSyntaxInInList() ) {
77587758
// Some DBs like Oracle support tuples only for the IN subquery predicate
7759-
if ( dialect.supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsUnionAll() ) {
7759+
if ( dialect.supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsValuesList() ) {
7760+
inListPredicate.getTestExpression().accept( this );
7761+
if ( inListPredicate.isNegated() ) {
7762+
appendSql( " not" );
7763+
}
7764+
appendSql( " in (select * from (values" );
7765+
char separator = ' ';
7766+
for ( Expression expression : listExpressions ) {
7767+
appendSql( separator );
7768+
appendSql( OPEN_PARENTHESIS );
7769+
renderCommaSeparated( getSqlTuple( expression ).getExpressions() );
7770+
appendSql( CLOSE_PARENTHESIS );
7771+
separator = ',';
7772+
}
7773+
appendSql( CLOSE_PARENTHESIS );
7774+
appendSql( CLOSE_PARENTHESIS );
7775+
}
7776+
else if ( dialect.supportsRowValueConstructorSyntaxInInSubQuery() && dialect.supportsUnionAll() ) {
77607777
inListPredicate.getTestExpression().accept( this );
77617778
if ( inListPredicate.isNegated() ) {
77627779
appendSql( " not" );

0 commit comments

Comments
 (0)