Skip to content

Commit c5c546b

Browse files
committed
Cleanup misuse of matchSubTypes in SkipForDialect for version matching
1 parent 50e87f4 commit c5c546b

File tree

52 files changed

+226
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+226
-110
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,56 @@ default boolean isSameOrAfter(int otherMajor, int otherMinor, int otherMicro) {
208208
|| ( major == otherMajor && minor == otherMinor && micro >= otherMicro );
209209
}
210210

211+
/**
212+
* {@link #isSame} or {@link #isBefore}
213+
*/
214+
default boolean isSameOrBefore(DatabaseVersion other) {
215+
return isSameOrBefore( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
216+
}
217+
218+
/**
219+
* {@link #isSame} or {@link #isBefore}
220+
*/
221+
default boolean isSameOrBefore(Integer otherMajor, Integer otherMinor) {
222+
return isSameOrBefore(
223+
(int) otherMajor,
224+
otherMinor == null ? NO_VERSION : otherMinor
225+
);
226+
}
227+
228+
/**
229+
* {@link #isSame} or {@link #isBefore}
230+
*/
231+
default boolean isSameOrBefore(int otherMajor) {
232+
final int major = getDatabaseMajorVersion();
233+
234+
return major <= otherMajor;
235+
}
236+
237+
/**
238+
* {@link #isSame} or {@link #isBefore}
239+
*/
240+
default boolean isSameOrBefore(int otherMajor, int otherMinor) {
241+
final int major = getDatabaseMajorVersion();
242+
final int minor = getDatabaseMinorVersion();
243+
244+
return major < otherMajor
245+
|| ( major == otherMajor && minor <= otherMinor );
246+
}
247+
248+
/**
249+
* {@link #isSame} or {@link #isBefore}
250+
*/
251+
default boolean isSameOrBefore(int otherMajor, int otherMinor, int otherMicro) {
252+
final int major = getDatabaseMajorVersion();
253+
final int minor = getDatabaseMinorVersion();
254+
final int micro = getDatabaseMicroVersion();
255+
256+
return major < otherMajor
257+
|| ( major == otherMajor && minor < otherMinor )
258+
|| ( major == otherMajor && minor == otherMinor && micro <= otherMicro );
259+
}
260+
211261
/**
212262
* Determine whether this version comes after the passed one
213263
*/

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/GenericsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@ServiceRegistry(settings = @Setting(name = Environment.AUTO_CLOSE_SESSION, value = "true"))
4040
public class GenericsTest {
4141

42-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "known bug in HANA: rs.next() returns false for org.hibernate.id.enhanced.SequenceStructure$1.getNextValue() for this test")
42+
@SkipForDialect(dialectClass = HANADialect.class, reason = "known bug in HANA: rs.next() returns false for org.hibernate.id.enhanced.SequenceStructure$1.getNextValue() for this test")
4343
@Test
4444
public void testManyToOneGenerics(SessionFactoryScope scope) {
4545
Paper white = new Paper();

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/QueryAndSQLTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
1616
import org.hibernate.cfg.AvailableSettings;
1717
import org.hibernate.dialect.HANADialect;
18-
import org.hibernate.dialect.PostgreSQLDialect;
1918
import org.hibernate.engine.spi.SessionFactoryImplementor;
2019
import org.hibernate.query.NativeQuery;
2120
import org.hibernate.query.Query;
@@ -119,7 +118,7 @@ public void testNativeQueryWithFormulaAttribute(SessionFactoryScope scope) {
119118
}
120119

121120
@Test
122-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "invalid name of function or procedure: SYSDATE")
121+
@SkipForDialect(dialectClass = HANADialect.class, reason = "invalid name of function or procedure: SYSDATE")
123122
public void testNativeQueryWithFormulaAttributeWithoutAlias(SessionFactoryScope scope) {
124123
scope.inTransaction(
125124
session -> {
@@ -596,8 +595,6 @@ public void testDiscriminator(SessionFactoryScope scope) {
596595
}
597596

598597
@Test
599-
@SkipForDialect(dialectClass = PostgreSQLDialect.class, matchSubTypes = true,
600-
reason = "postgresql jdbc driver does not implement the setQueryTimeout method")
601598
public void testCache(SessionFactoryScope scope) {
602599
Plane plane = new Plane();
603600
scope.inTransaction(

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/uniqueconstraint/UniqueConstraintTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
@DomainModel( annotatedClasses = { Room.class, Building.class, House.class } )
2828
@SessionFactory
2929
@SkipForDialect( dialectClass = InformixDialect.class,
30-
matchSubTypes = true,
3130
reason = "Informix does not properly support unique constraints on nullable columns" )
3231
@SkipForDialect( dialectClass = SybaseDialect.class,
3332
matchSubTypes = true,

hibernate-core/src/test/java/org/hibernate/orm/test/cache/CollectionCacheEvictionComplexIdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
@SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 5, reason = "BLOB/TEXT column 'id' used in key specification without a key length")
39-
@SkipForDialect(dialectClass = OracleDialect.class, matchSubTypes = true, reason = "ORA-02329: column of datatype LOB cannot be unique or a primary key")
39+
@SkipForDialect(dialectClass = OracleDialect.class, reason = "ORA-02329: column of datatype LOB cannot be unique or a primary key")
4040
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Informix does not support unique / primary constraints on binary columns")
4141
@DomainModel(
4242
annotatedClasses = {

hibernate-core/src/test/java/org/hibernate/orm/test/function/array/ArrayTrimTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.hibernate.dialect.CockroachDialect;
1212
import org.hibernate.dialect.PostgreSQLDialect;
13+
import org.hibernate.dialect.PostgresPlusDialect;
1314
import org.hibernate.query.criteria.JpaCriteriaQuery;
1415
import org.hibernate.query.criteria.JpaRoot;
1516
import org.hibernate.query.sqm.NodeBuilder;
@@ -22,6 +23,7 @@
2223
import org.hibernate.testing.orm.junit.SessionFactory;
2324
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2425
import org.hibernate.testing.orm.junit.SkipForDialect;
26+
import org.hibernate.testing.orm.junit.VersionMatchMode;
2527
import org.junit.jupiter.api.AfterEach;
2628
import org.junit.jupiter.api.BeforeEach;
2729
import org.junit.jupiter.api.Test;
@@ -84,7 +86,8 @@ public void testTrimAll(SessionFactoryScope scope) {
8486
}
8587

8688
@Test
87-
@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 13, matchSubTypes = true, reason = "The PostgreSQL emulation for version < 14 doesn't throw an error")
89+
@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 14, versionMatchMode = VersionMatchMode.SAME_OR_NEWER, reason = "The PostgreSQL emulation for version < 14 doesn't throw an error")
90+
@SkipForDialect(dialectClass = PostgresPlusDialect.class, majorVersion = 14, versionMatchMode = VersionMatchMode.SAME_OR_NEWER, reason = "The PostgreSQL emulation for version < 14 doesn't throw an error")
8891
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "The Cockroach emulation doesn't throw an error")
8992
public void testTrimOutOfRange(SessionFactoryScope scope) {
9093
scope.inSession( em -> {

hibernate-core/src/test/java/org/hibernate/orm/test/function/json/JsonExistsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2323
import org.hibernate.testing.orm.junit.Setting;
2424
import org.hibernate.testing.orm.junit.SkipForDialect;
25+
import org.hibernate.testing.orm.junit.VersionMatchMode;
2526
import org.junit.jupiter.api.AfterEach;
2627
import org.junit.jupiter.api.BeforeEach;
2728
import org.junit.jupiter.api.Test;
@@ -71,7 +72,7 @@ public void testSimple(SessionFactoryScope scope) {
7172
}
7273

7374
@Test
74-
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 21, matchSubTypes = true, reason = "Oracle bug in versions before 23")
75+
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 23, versionMatchMode = VersionMatchMode.OLDER, reason = "Oracle bug in versions before 23")
7576
public void testPassing(SessionFactoryScope scope) {
7677
scope.inSession( em -> {
7778
//tag::hql-json-exists-passing-example[]

hibernate-core/src/test/java/org/hibernate/orm/test/function/json/JsonObjectAggregateTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.hibernate.dialect.HANADialect;
1111
import org.hibernate.dialect.MySQLDialect;
1212
import org.hibernate.dialect.PostgreSQLDialect;
13+
import org.hibernate.dialect.PostgresPlusDialect;
1314
import org.hibernate.dialect.SQLServerDialect;
1415

1516
import org.hibernate.testing.orm.domain.StandardDomainModel;
@@ -21,6 +22,7 @@
2122
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2223
import org.hibernate.testing.orm.junit.Setting;
2324
import org.hibernate.testing.orm.junit.SkipForDialect;
25+
import org.hibernate.testing.orm.junit.VersionMatchMode;
2426
import org.junit.jupiter.api.Test;
2527

2628
/**
@@ -56,7 +58,8 @@ public void testNull(SessionFactoryScope scope) {
5658
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA has no way to throw an error on duplicate json object keys.")
5759
@SkipForDialect(dialectClass = DB2Dialect.class, reason = "DB2 has no way to throw an error on duplicate json object keys.")
5860
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "CockroachDB has no way to throw an error on duplicate json object keys.")
59-
@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 15, matchSubTypes = true, reason = "CockroachDB has no way to throw an error on duplicate json object keys.")
61+
@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 15, versionMatchMode = VersionMatchMode.SAME_OR_OLDER, reason = "Before version 16, PostgreSQL didn't support the unique keys clause.")
62+
@SkipForDialect(dialectClass = PostgresPlusDialect.class, majorVersion = 15, versionMatchMode = VersionMatchMode.SAME_OR_OLDER, reason = "Before version 16, PostgresPlus didn't support the unique keys clause.")
6063
public void testUniqueKeys(SessionFactoryScope scope) {
6164
scope.inSession( em -> {
6265
//tag::hql-json-objectagg-unique-keys-example[]

hibernate-core/src/test/java/org/hibernate/orm/test/hql/ScrollableCollectionFetchingTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import org.hibernate.dialect.HANADialect;
1111
import org.hibernate.dialect.DB2Dialect;
1212
import org.hibernate.community.dialect.DerbyDialect;
13-
import org.hibernate.dialect.SybaseASEDialect;
1413

14+
import org.hibernate.dialect.SybaseASEDialect;
1515
import org.hibernate.query.SemanticException;
1616
import org.hibernate.query.sqm.UnknownPathException;
1717
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
@@ -20,6 +20,7 @@
2020
import org.hibernate.testing.orm.junit.SessionFactory;
2121
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2222
import org.hibernate.testing.orm.junit.SkipForDialect;
23+
import org.hibernate.testing.orm.junit.VersionMatchMode;
2324
import org.junit.jupiter.api.AfterEach;
2425
import org.junit.jupiter.api.Test;
2526

@@ -44,8 +45,8 @@
4445
public class ScrollableCollectionFetchingTest {
4546

4647
@Test
47-
@SkipForDialect(dialectClass=DB2Dialect.class, matchSubTypes = true)
48-
@SkipForDialect(dialectClass= DerbyDialect.class)
48+
@SkipForDialect(dialectClass = DB2Dialect.class, matchSubTypes = true)
49+
@SkipForDialect(dialectClass = DerbyDialect.class)
4950
public void testTupleReturnWithFetch(SessionFactoryScope scope) {
5051
scope.inTransaction(
5152
session -> {
@@ -94,8 +95,8 @@ public void testUknownPathFailure(SessionFactoryScope scope) {
9495
}
9596

9697
@Test
97-
@SkipForDialect(dialectClass = SybaseASEDialect.class, majorVersion = 15, matchSubTypes = true, reason = "HHH-5229")
98-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
98+
@SkipForDialect(dialectClass = SybaseASEDialect.class, majorVersion = 15, versionMatchMode = VersionMatchMode.SAME_OR_OLDER, reason = "HHH-5229")
99+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
99100
public void testScrollingJoinFetchesEmptyResultSet(SessionFactoryScope scope) {
100101
scope.inTransaction(
101102
s -> {
@@ -163,7 +164,7 @@ public void testScrollingJoinFetchesEmptyResultSet(SessionFactoryScope scope) {
163164

164165
@Test
165166
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
166-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors")
167+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors")
167168
public void testScrollingJoinFetchesSingleRowResultSet(SessionFactoryScope scope) {
168169

169170
scope.inTransaction(
@@ -314,7 +315,7 @@ public void testScrollingJoinFetchesForward(SessionFactoryScope scope) {
314315

315316
@Test
316317
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
317-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
318+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
318319
public void testScrollingJoinFetchesReverse(SessionFactoryScope scope) {
319320
TestData data = new TestData();
320321
data.prepare( scope );
@@ -342,7 +343,7 @@ public void testScrollingJoinFetchesReverse(SessionFactoryScope scope) {
342343

343344
@Test
344345
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
345-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
346+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
346347
public void testScrollingJoinFetchesWithNext(SessionFactoryScope scope) {
347348
TestData data = new TestData();
348349
data.prepare( scope );
@@ -374,7 +375,7 @@ public void testScrollingJoinFetchesWithNext(SessionFactoryScope scope) {
374375

375376
@Test
376377
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
377-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
378+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
378379
public void testScrollingNoJoinFetchesWithNext(SessionFactoryScope scope) {
379380
TestData data = new TestData();
380381
data.prepare( scope );
@@ -406,7 +407,7 @@ public void testScrollingNoJoinFetchesWithNext(SessionFactoryScope scope) {
406407

407408
@Test
408409
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
409-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
410+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
410411
public void testScrollingJoinFetchesPositioning(SessionFactoryScope scope) {
411412
TestData data = new TestData();
412413
data.prepare( scope );
@@ -474,7 +475,7 @@ public void testScrollingJoinFetchesPositioning(SessionFactoryScope scope) {
474475

475476
@Test
476477
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
477-
@SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
478+
@SkipForDialect(dialectClass = HANADialect.class, reason = "HANA only supports forward-only cursors.")
478479
public void testScrollingNoJoinFetchesPositioning(SessionFactoryScope scope) {
479480
TestData data = new TestData();
480481
data.prepare( scope );

hibernate-core/src/test/java/org/hibernate/orm/test/id/QuotedIdentifierTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hibernate.testing.orm.junit.SessionFactory;
2020
import org.hibernate.testing.orm.junit.SessionFactoryScope;
2121
import org.hibernate.testing.orm.junit.SkipForDialect;
22+
import org.hibernate.testing.orm.junit.VersionMatchMode;
2223
import org.junit.jupiter.api.Test;
2324

2425
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -27,7 +28,7 @@
2728
* @author Vlad Mihalcea
2829
*/
2930
@RequiresDialectFeature(feature = SupportsIdentityColumns.class, jiraKey = "HHH-9271")
30-
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 12, matchSubTypes = true, reason = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
31+
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 12, versionMatchMode = VersionMatchMode.SAME_OR_OLDER, reason = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
3132
@DomainModel(
3233
annotatedClasses = {
3334
QuotedIdentifierTest.QuotedIdentifier.class

0 commit comments

Comments
 (0)