Skip to content
Prev Previous commit
Next Next commit
Fixing issue when a hash was tried to be generated on the null value …
…from XML extract causing to fail. Please see #1098

Resolve a situation where a more than two levels of nesting were causing ambiguity on the column name for hash.
E.g.
<OBJ1><FIRST><VAL><TEST>
<OBJ1><SECOND><VAL><TEST>
Was taking into hash consideration only parent.
  • Loading branch information
lwasylow committed Jan 26, 2022
commit 3c3d32055457a9c4ab36e61cc79179a536e2f8aa
6 changes: 4 additions & 2 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,14 @@ create or replace package body ut_utils is

function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is
begin
return dbms_crypto.hash(a_data, a_hash_type);
--We cannot run hash on null
return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end;
end;

function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is
begin
return dbms_crypto.hash(a_data, a_hash_type);
--We cannot run hash on null
return case when a_data is null then null else dbms_crypto.hash(a_data, a_hash_type) end;
end;

function qualified_sql_name(a_name varchar2) return varchar2 is
Expand Down
5 changes: 3 additions & 2 deletions source/expectations/data_values/ut_cursor_column.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ create or replace type body ut_cursor_column as
a_access_path||'/'||self.xml_valid_name
end; --Access path used for XMLTABLE query
self.filter_path := '/'||self.access_path; --Filter path will differ from access path in anydata type
--Transformed name needs to be build on full access path to avoid ambiguity when there is 3 or more levels of nesting.
self.transformed_name := case when length(self.xml_valid_name) > 30 then
'"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"'
'"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"'
when self.parent_name is null then
'"'||self.xml_valid_name||'"'
else
'"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.xml_valid_name)||'"'
'"'||ut_compound_data_helper.get_fixed_size_hash(self.access_path)||'"'
end; --when is nestd we need to hash name to make sure we dont exceed 30 char
self.column_type := a_col_type; --column type e.g. user_defined , varchar2
self.column_schema := a_col_schema_name; -- schema name
Expand Down