Fix some JSON function rendering issues on HANA

This commit is contained in:
Christian Beikov 2024-11-21 10:13:20 +01:00
parent 4a2ee83d0c
commit bcd70a82c4
2 changed files with 2 additions and 8 deletions

View File

@ -115,7 +115,7 @@ public class HANAAggregateSupport extends AggregateSupportImpl {
if ( SqlTypes.isBinaryType( column.getJdbcMapping().getJdbcType().getDdlTypeCode() ) ) {
return template.replace(
placeholder,
"hextobin(json_value(" + parentPartExpression + columnExpression + "'))"
"hextobin(replace(json_value(" + parentPartExpression + columnExpression + "'),'-',''))"
);
}
// Fall-through intended

View File

@ -71,19 +71,13 @@ public class HANAJsonObjectAggFunction extends JsonObjectAggFunction {
sqlAppender.appendSql( " as nvarchar(" + Integer.MAX_VALUE + "))" );
}
else {
if ( nullBehavior != JsonNullBehavior.NULL ) {
sqlAppender.appendSql( "nullif(" );
}
sqlAppender.appendSql( "json_query((select " );
arg.accept( translator );
sqlAppender.appendSql( " V from sys.dummy for json('arraywrap'='no'" );
if ( nullBehavior != JsonNullBehavior.NULL ) {
if ( nullBehavior == JsonNullBehavior.NULL ) {
sqlAppender.appendSql( ",'omitnull'='no'" );
}
sqlAppender.appendSql( ") returns nvarchar(" + Integer.MAX_VALUE + ")),'$.V')" );
if ( nullBehavior != JsonNullBehavior.NULL ) {
sqlAppender.appendSql( ",'null')" );
}
}
}
}