Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b0e6d1

Browse files
authored
Merge pull request #913 from utPLSQL/fix/exclude_column_position
Fix/exclude column position
2 parents 541809e + e088211 commit 0b0e6d1

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

source/expectations/data_values/ut_cursor_details.tpb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ create or replace type body ut_cursor_details as
160160

161161
member procedure filter_columns(self in out nocopy ut_cursor_details, a_match_options ut_matcher_options) is
162162
l_result ut_cursor_details := self;
163+
l_column_tab ut_cursor_column_tab := ut_cursor_column_tab();
164+
l_column ut_cursor_column;
163165
c_xpath_extract_reg constant varchar2(50) := '^((/ROW/)|^(//)|^(/\*/))?(.*)';
164166
begin
165167
if l_result.cursor_columns_info is not null then
@@ -194,6 +196,24 @@ create or replace type body ut_cursor_details as
194196
select 1 from excluded_columns f where regexp_like( '/'||x.access_path, '^/?'||f.col_names||'($|/.*)' )
195197
);
196198
end if;
199+
200+
--Rewrite column order after columns been excluded
201+
for i in (
202+
select parent_name, access_path, display_path, has_nested_col,
203+
transformed_name, hierarchy_level,
204+
rownum as new_position, xml_valid_name,
205+
column_name, column_type, column_type_name, column_schema,
206+
column_len, column_precision ,column_scale ,is_sql_diffable, is_collection,value(x) col_info
207+
from table(l_result.cursor_columns_info) x
208+
order by x.column_position asc
209+
) loop
210+
l_column := i.col_info;
211+
l_column.column_position := i.new_position;
212+
l_column_tab.extend;
213+
l_column_tab(l_column_tab.last) := l_column;
214+
end loop;
215+
216+
l_result.cursor_columns_info := l_column_tab;
197217
self := l_result;
198218
end if;
199219
end;

test/ut3_user/expectations/test_expectations_cursor.pkb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,5 +2831,17 @@ Check the query and data for errors.';
28312831
$end
28322832
end;
28332833

2834+
procedure uc_columns_exclude is
2835+
v_actual SYS_REFCURSOR;
2836+
v_expected SYS_REFCURSOR;
2837+
begin
2838+
open v_expected for
2839+
select to_Char(null) id, 'ok' name from dual;
2840+
open v_actual for
2841+
select 'ok' name, to_number(null) id from dual;
2842+
2843+
ut3.ut.expect(v_actual).to_equal(v_expected).exclude('ID');
2844+
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
2845+
end;
28342846
end;
28352847
/

test/ut3_user/expectations/test_expectations_cursor.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,8 @@ create or replace package test_expectations_cursor is
459459

460460
type t_num_tab is table of t_num_rec index by binary_integer;
461461

462+
--%test( Mixed column order exclusion )
463+
procedure uc_columns_exclude;
464+
462465
end;
463466
/

0 commit comments

Comments
 (0)