Skip to content

Commit 6cf3908

Browse files
committed
Additional support for older Informix versions
1 parent 024df84 commit 6cf3908

File tree

2 files changed

+23
-4
lines changed
  • hibernate-community-dialects/src/main/java/org/hibernate/community/dialect
  • hibernate-core/src/test/java/org/hibernate/orm/test/hql

2 files changed

+23
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
466466
@Override
467467
public String extractPattern(TemporalUnit unit) {
468468
return switch ( unit ) {
469-
case SECOND -> "to_number(to_char(?2,'%S.%F3'))";
469+
case SECOND -> getVersion().isBefore( 11, 70 ) ? "to_number(to_char(?2,'%S%F3'))" : "to_number(to_char(?2,'%S.%F3'))";
470470
case MINUTE -> "to_number(to_char(?2,'%M'))";
471471
case HOUR -> "to_number(to_char(?2,'%H'))";
472472
case DAY_OF_WEEK -> "(weekday(?2)+1)";
@@ -536,8 +536,8 @@ public String getAddPrimaryKeyConstraintString(String constraintName) {
536536

537537
@Override
538538
public String getTruncateTableStatement(String tableName) {
539-
return super.getTruncateTableStatement( tableName )
540-
+ " reuse storage keep statistics";
539+
return super.getTruncateTableStatement( tableName ) + " reuse storage"
540+
+ ( getVersion().isSameOrAfter( 12, 10 ) ? " keep statistics" : "" );
541541
}
542542

543543
@Override
@@ -751,7 +751,7 @@ public boolean isCurrentTimestampSelectStringCallable() {
751751

752752
@Override
753753
public String getCurrentTimestampSelectString() {
754-
return "select sysdate";
754+
return "select sysdate" + (getVersion().isBefore( 12, 10 ) ? " from informix.systables where tabid=1" : "");
755755
}
756756

757757
@Override @SuppressWarnings("deprecation")
@@ -1121,6 +1121,16 @@ public boolean supportsCrossJoin() {
11211121
return false;
11221122
}
11231123

1124+
@Override
1125+
public boolean supportsIntersect(){
1126+
return getVersion().isSameOrAfter( 12,10 );
1127+
}
1128+
1129+
public boolean supportsSubqueryOnMutatingTable() {
1130+
//tested on version 11.50, 14.10
1131+
return getVersion().isAfter( 11, 50);
1132+
}
1133+
11241134
@Override
11251135
public boolean supportsRowValueConstructorSyntax() {
11261136
return false;
@@ -1136,6 +1146,11 @@ public boolean supportsRowValueConstructorSyntaxInInList() {
11361146
return false;
11371147
}
11381148

1149+
@Override
1150+
public boolean supportsWithClause() {
1151+
return getVersion().isSameOrAfter( 14,10 );
1152+
}
1153+
11391154
@Override
11401155
public boolean requiresColumnListInCreateView() {
11411156
return true;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,7 @@ public void test_hql_aggregate_functions_example_3() {
14871487
}
14881488

14891489
@Test
1490+
@SkipForDialect( dialectClass = InformixDialect.class, majorVersion = 11, minorVersion = 50, reason = "Informix does not support case expressions within count function")
14901491
public void test_hql_aggregate_functions_simple_filter_example() {
14911492
doInJPA(this::entityManagerFactory, entityManager -> {
14921493
//tag::hql-aggregate-functions-simple-filter-example[]
@@ -1502,6 +1503,7 @@ public void test_hql_aggregate_functions_simple_filter_example() {
15021503
}
15031504

15041505
@Test
1506+
@SkipForDialect( dialectClass = InformixDialect.class, majorVersion = 11, minorVersion = 50, reason = "Informix does not support case expressions within count function")
15051507
public void test_hql_aggregate_functions_filter_example() {
15061508
doInJPA(this::entityManagerFactory, entityManager -> {
15071509
//tag::hql-aggregate-functions-filter-example[]
@@ -1647,6 +1649,7 @@ public void test_hql_length_function_example() {
16471649
}
16481650

16491651
@Test
1652+
@SkipForDialect( dialectClass = InformixDialect.class, majorVersion = 11, minorVersion = 70, reason = "Informix does not support locate function")
16501653
public void test_hql_locate_function_example() {
16511654
doInJPA(this::entityManagerFactory, entityManager -> {
16521655
//tag::hql-locate-function-example[]
@@ -1661,6 +1664,7 @@ public void test_hql_locate_function_example() {
16611664
}
16621665

16631666
@Test
1667+
@SkipForDialect( dialectClass = InformixDialect.class, majorVersion = 11, minorVersion = 70, reason = "Informix does not support position function")
16641668
public void test_hql_position_function_example() {
16651669
doInJPA(this::entityManagerFactory, entityManager -> {
16661670
//tag::hql-position-function-example[]

0 commit comments

Comments
 (0)