Skip to content

Commit 1ee18f7

Browse files
committed
HHH-19260 - Move supportsRowValueConstructorDistinctFromSyntax() to Dialect
Signed-off-by: Jan Schatteman <[email protected]>
1 parent d24a920 commit 1ee18f7

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,4 +1090,10 @@ public boolean supportsRowValueConstructorSyntax() {
10901090
return getVersion().isSameOrAfter( 1, 4, 197 );
10911091
}
10921092

1093+
@Override
1094+
public boolean supportsRowValueConstructorDistinctFromSyntax() {
1095+
// Seems that before, this was buggy
1096+
return getVersion().isSameOrAfter( 1, 4, 200 );
1097+
}
1098+
10931099
}

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacySqlAstTranslator.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
358358
return getDialect().getVersion().isSameOrAfter( 1, 4, 197 );
359359
}
360360

361-
@Override
362-
protected boolean supportsRowValueConstructorDistinctFromSyntax() {
363-
// Seems that before, this was buggy
364-
return getDialect().getVersion().isSameOrAfter( 1, 4, 200 );
365-
}
366-
367361
protected boolean allowsNullPrecedence() {
368362
return getClauseStack().getCurrent() != Clause.WITHIN_GROUP || getDialect().supportsNullPrecedence();
369363
}

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5984,4 +5984,19 @@ public boolean supportsRowValueConstructorGtLtSyntax() {
59845984
return supportsRowValueConstructorSyntax();
59855985
}
59865986

5987+
/**
5988+
* Is this dialect known to support what ANSI-SQL terms "row value
5989+
* constructor" syntax; sometimes called tuple syntax with <code>is distinct from</code>
5990+
* and <code>is not distinct from</code> operators.
5991+
* <p>
5992+
* Basically, does it support syntax like
5993+
* {@code ... where (FIRST_NAME, LAST_NAME) is distinct from ('Steve', 'Ebersole') ...}
5994+
*
5995+
* @return True if this SQL dialect is known to support "row value
5996+
* constructor" syntax with distinct from comparison operators; false otherwise.
5997+
*/
5998+
public boolean supportsRowValueConstructorDistinctFromSyntax() {
5999+
return supportsRowValueConstructorSyntax() && supportsDistinctFromPredicate();
6000+
}
6001+
59876002
}

hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,4 +1110,9 @@ public boolean supportsRowValueConstructorSyntax() {
11101110
return true;
11111111
}
11121112

1113+
@Override
1114+
public boolean supportsRowValueConstructorDistinctFromSyntax() {
1115+
return true;
1116+
}
1117+
11131118
}

hibernate-core/src/main/java/org/hibernate/dialect/H2SqlAstTranslator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
331331
return true;
332332
}
333333

334-
@Override
335-
protected boolean supportsRowValueConstructorDistinctFromSyntax() {
336-
return true;
337-
}
338-
339334
private boolean supportsOffsetFetchClause() {
340335
return true;
341336
}

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

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6456,7 +6456,7 @@ protected Predicate determineLateralEmulationPredicate(TableGroup tableGroup) {
64566456

64576457
// The following optimization only makes sense if the necessary features are supported natively
64586458
if ( ( columnReferences.size() == 1 || dialect.supportsRowValueConstructorSyntax() )
6459-
&& supportsRowValueConstructorDistinctFromSyntax() ) {
6459+
&& dialect.supportsRowValueConstructorDistinctFromSyntax() ) {
64606460
// Special case for limit 1 sub-queries to avoid double nested sub-query
64616461
// ... x(c) on x.c is not distinct from (... fetch first 1 rows only)
64626462
if ( isFetchFirstRowOnly( statement.getQueryPart() ) ) {
@@ -8415,26 +8415,11 @@ private boolean needsTupleComparisonEmulation(ComparisonOperator operator) {
84158415
case LESS_THAN, LESS_THAN_OR_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL ->
84168416
!dialect.supportsRowValueConstructorGtLtSyntax();
84178417
case DISTINCT_FROM, NOT_DISTINCT_FROM ->
8418-
!supportsRowValueConstructorDistinctFromSyntax();
8418+
!dialect.supportsRowValueConstructorDistinctFromSyntax();
84198419
default -> false;
84208420
};
84218421
}
84228422

8423-
/**
8424-
* Is this dialect known to support what ANSI-SQL terms "row value
8425-
* constructor" syntax; sometimes called tuple syntax with <code>is distinct from</code>
8426-
* and <code>is not distinct from</code> operators.
8427-
* <p>
8428-
* Basically, does it support syntax like
8429-
* {@code ... where (FIRST_NAME, LAST_NAME) is distinct from ('Steve', 'Ebersole') ...}
8430-
*
8431-
* @return True if this SQL dialect is known to support "row value
8432-
* constructor" syntax with distinct from comparison operators; false otherwise.
8433-
*/
8434-
protected boolean supportsRowValueConstructorDistinctFromSyntax() {
8435-
return dialect.supportsRowValueConstructorSyntax() && dialect.supportsDistinctFromPredicate();
8436-
}
8437-
84388423
/**
84398424
* Is this dialect known to support what ANSI-SQL terms "row value
84408425
* constructor" syntax; sometimes called tuple syntax with quantified predicates.

0 commit comments

Comments
 (0)