@@ -32,10 +32,16 @@ create or replace type body ut_data_value_anydata as
3232 end;
3333
3434 overriding member function compare_implementation(a_other ut_data_value) return integer is
35+ begin
36+ return compare_implementation( a_other, null, null);
37+ end;
38+
39+ member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2) return integer is
3540 l_self_data xmltype;
3641 l_other_data xmltype;
3742 l_other ut_data_value_anydata;
3843 l_result integer;
44+ l_ancestors varchar2(20);
3945 procedure filter_by_xpaths(a_xml in out nocopy xmltype, a_exclude varchar2, a_include varchar2) is
4046 begin
4147 if a_exclude is not null then
@@ -50,17 +56,16 @@ create or replace type body ut_data_value_anydata as
5056 l_other := treat(a_other as ut_data_value_anydata);
5157 --needed for 11g xe as it fails on constructing XMLTYPE from null ANYDATA
5258 if not self.is_null() and not l_other.is_null() then
59+ if self is of (ut_data_value_object) then
60+ l_ancestors := '/*/';
61+ else
62+ l_ancestors := '/*/*/';
63+ end if;
5364 ut_expectation_processor.set_xml_nls_params();
5465 l_self_data := xmltype.createxml(self.data_value);
5566 l_other_data := xmltype.createxml(l_other.data_value);
56- --We use `order member function compare` to do data comparison.
57- --Therefore, in the `ut_equals` matcher, comparison is done by simply checking
58- -- `l_result := equal_with_nulls((self.expected = a_actual), a_actual)`
59- --We cannot guarantee that we will always use `expected = actual ` and not `actual = expected`.
60- --We should expect the same behaviour regardless of that is the order.
61- -- This is why we need to coalesce `exclude_xpath` though at most one of them will always be populated
62- filter_by_xpaths(l_self_data, coalesce(self.exclude_xpath, l_other.exclude_xpath), coalesce(self.include_xpath, l_other.include_xpath));
63- filter_by_xpaths(l_other_data, coalesce(self.exclude_xpath, l_other.exclude_xpath), coalesce(self.include_xpath, l_other.include_xpath));
67+ filter_by_xpaths(l_self_data, a_exclude_xpath, a_include_xpath);
68+ filter_by_xpaths(l_other_data, a_exclude_xpath, a_include_xpath);
6469 ut_expectation_processor.reset_nls_params();
6570 if l_self_data is not null and l_other_data is not null then
6671 l_result := dbms_lob.compare( l_self_data.getclobval(), l_other_data.getclobval() );
@@ -94,10 +99,9 @@ create or replace type body ut_data_value_anydata as
9499 return self.data_value is null or ut_utils.int_to_boolean(self.data_value_is_null);
95100 end;
96101
97- static function get_instance(a_data_value anydata, a_exclude varchar2 := null, a_include varchar2 := null ) return ut_data_value_anydata is
102+ static function get_instance(a_data_value anydata) return ut_data_value_anydata is
98103 l_result ut_data_value_anydata := ut_data_value_object(null);
99104 l_type anytype;
100- l_ancestors varchar2(20) := '/*/';
101105 l_type_code integer;
102106 begin
103107 if a_data_value is not null then
@@ -107,27 +111,13 @@ create or replace type body ut_data_value_anydata as
107111 l_result := ut_data_value_object(a_data_value);
108112 else
109113 l_result := ut_data_value_collection(a_data_value);
110- l_ancestors := '/*/*/';
111114 end if;
112- l_result.exclude_xpath := ut_utils.to_xpath( a_exclude, l_ancestors );
113- l_result.include_xpath := ut_utils.to_xpath( a_include, l_ancestors );
114115 else
115116 raise_application_error(-20000, 'Data type '||a_data_value.gettypename||' in ANYDATA is not supported by utPLSQL');
116117 end if;
117118 end if;
118119 return l_result;
119120 end;
120121
121- static function get_instance(a_data_value anydata, a_exclude ut_varchar2_list, a_include ut_varchar2_list) return ut_data_value_anydata is
122- l_result ut_data_value_anydata;
123- l_exclude varchar2(32767);
124- l_include varchar2(32767);
125- begin
126- l_exclude := substr(ut_utils.table_to_clob(a_exclude, ','), 1, 32767);
127- l_include := substr(ut_utils.table_to_clob(a_include, ','), 1, 32767);
128- l_result := ut_data_value_anydata.get_instance(a_data_value, l_exclude, l_include );
129- return l_result;
130- end;
131-
132122end;
133123/
0 commit comments