Skip to content

Commit

Permalink
HHH-18765 - fix error in the booleanarray_to_string auxiliary functio…
Browse files Browse the repository at this point in the history
…n for Oracle

Signed-off-by: Jan Schatteman <[email protected]>
  • Loading branch information
jrenaat committed Oct 24, 2024
1 parent 7bf6004 commit 351e3b4
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ public String[] getSqlCreateStrings(
dialect
);
final String valueExpression = determineValueExpression( "t.value", elementSqlTypeCode, elementType );
boolean isBooleanType = elementType.equalsIgnoreCase( "boolean" );
return new String[] {
"create or replace type " + arrayTypeName + " as varying array(" + arrayLength + ") of " + elementType,
!isBooleanType ? "" :
"create or replace function boolean_to_char(bool in boolean) return varchar2 is begin " +
"return " +
"case bool " +
"when true then 'true' " +
"when false then 'false' " +
"else 'null' " +
"end; " +
"end;",
"create or replace function " + arrayTypeName + "_cmp(a in " + arrayTypeName +
", b in " + arrayTypeName + ") return number deterministic is begin " +
"if a is null or b is null then return null; end if; " +
Expand Down Expand Up @@ -252,7 +262,7 @@ public String[] getSqlCreateStrings(
"for i in 1 .. arr.count loop " +
"if arr(i) is not null then " +
"if length(res)<>0 then res:=res||sep; end if; " +
"res:=res||arr(i); " +
(!isBooleanType ? "res:=res||arr(i); " : "res:=res||boolean_to_char(arr(i)); ") +
"elsif nullVal is not null then " +
"if length(res)<>0 then res:=res||sep; end if; " +
"res:=res||nullVal; " +
Expand Down

0 comments on commit 351e3b4

Please sign in to comment.