Skip to content

Commit 58ed57d

Browse files
committed
fix 'select null' on Informix
1 parent 6f44701 commit 58ed57d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -951,17 +951,22 @@ public void appendDateTimeLiteral(SqlAppender appender, Date date, TemporalType
951951

952952
@Override
953953
public String getSelectClauseNullString(int sqlType, TypeConfiguration typeConfiguration) {
954-
DdlType descriptor = typeConfiguration.getDdlTypeRegistry().getDescriptor( sqlType );
954+
final DdlType descriptor = typeConfiguration.getDdlTypeRegistry().getDescriptor( sqlType );
955955
if ( descriptor == null ) {
956-
return "null";
956+
// just cast it to an arbitrary SQL type,
957+
// which we expect to be ignored by higher layers
958+
return "null::int";
957959
}
958-
String typeName = descriptor.getTypeName( Size.length( Size.DEFAULT_LENGTH ) );
960+
else {
961+
return "null::" + castType( descriptor );
962+
}
963+
}
964+
965+
private static String castType(DdlType descriptor) {
966+
final String typeName = descriptor.getTypeName( Size.length( Size.DEFAULT_LENGTH ) );
959967
//trim off the length/precision/scale
960968
final int loc = typeName.indexOf( '(' );
961-
if ( loc > -1 ) {
962-
typeName = typeName.substring( 0, loc );
963-
}
964-
return "null::" + typeName;
969+
return loc < 0 ? typeName : typeName.substring( 0, loc );
965970
}
966971

967972
@Override

0 commit comments

Comments
 (0)