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

Skip to content

Commit 2ff110d

Browse files
committed
Change cursor behaviour to be ordered columns by default.
1 parent ada957d commit 2ff110d

6 files changed

Lines changed: 24 additions & 24 deletions

File tree

docs/userguide/expectations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ utPLSQL is capable of comparing compound data-types including:
713713

714714
- Attributes in nested table and array types are compared as **ordered lists of elements**. If order of attributes in nested table and array differ, expectation will fail.
715715

716-
- Columns in cursors are compared as **unordered list of elements** by default. If order of columns in cursor is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
716+
- Columns in cursors are compared as **ordered list of elements** by default. If order of columns in cursor is not of importance the option has to be passed to enforce column order comparison ` unordered_columns` e.g.
717717

718718
```sql
719719
procedure ut_refcursors1 is
@@ -725,7 +725,7 @@ utPLSQL is capable of comparing compound data-types including:
725725
open l_actual for select 1 user_id,'s' a_col,'test' username from dual;
726726
open l_expected for select 'test' username,'s' a_col,1 user_id from dual;
727727
--Act
728-
ut.expect(l_actual).to_equal(l_expected).join_by('USER_ID').ordered_columns;
728+
ut.expect(l_actual).to_equal(l_expected).join_by('USER_ID').unordered_columns;
729729
end;
730730
```
731731

@@ -821,7 +821,7 @@ create or replace package body test_cursor_compare as
821821
from dual union all
822822
select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY
823823
from dual;
824-
ut.expect(l_actual).to_equal(l_expected).ordered_columns;
824+
ut.expect(l_actual).to_equal(l_expected);
825825
end;
826826
end;
827827
/

source/expectations/matchers/ut_equal.tpb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ create or replace type body ut_equal as
254254
return ( coalesce(join_columns, ut_varchar2_list()) );
255255
end;
256256

257-
member function ordered_columns return ut_equal is
257+
member function unordered_columns return ut_equal is
258258
l_result ut_equal := self;
259259
begin
260-
l_result.is_column_order_enforced := ut_utils.boolean_to_int(true);
260+
l_result.is_column_order_enforced := ut_utils.boolean_to_int(false);
261261
return l_result;
262262
end;
263263

264264
member function get_ordered_columns return boolean is
265265
begin
266-
return ut_utils.int_to_boolean(nvl(is_column_order_enforced,0));
266+
return ut_utils.int_to_boolean(nvl(is_column_order_enforced,1));
267267
end;
268268

269269
overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean is

source/expectations/matchers/ut_equal.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ create or replace type ut_equal force under ut_comparison_matcher(
8181
overriding member function run_matcher(self in out nocopy ut_equal, a_actual ut_data_value) return boolean,
8282
overriding member function failure_message(a_actual ut_data_value) return varchar2,
8383
overriding member function failure_message_when_negated(a_actual ut_data_value) return varchar2,
84-
member function ordered_columns return ut_equal,
84+
member function unordered_columns return ut_equal,
8585
member function get_ordered_columns return boolean
8686
)
8787
not final

source/expectations/ut_expectation_compound.tpb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,21 @@ create or replace type body ut_expectation_compound as
227227
end if;
228228
end;
229229

230-
member function ordered_columns return ut_expectation_compound is
230+
member function unordered_columns return ut_expectation_compound is
231231
l_result ut_expectation_compound;
232232
begin
233233
l_result := self;
234-
l_result.matcher := treat(l_result.matcher as ut_equal).ordered_columns;
234+
l_result.matcher := treat(l_result.matcher as ut_equal).unordered_columns;
235235
return l_result;
236236
end;
237237

238-
member procedure ordered_columns(self in ut_expectation_compound) is
238+
member procedure unordered_columns(self in ut_expectation_compound) is
239239
begin
240240

241241
if ut_utils.int_to_boolean(negated) then
242-
self.not_to( treat(matcher as ut_equal).ordered_columns );
242+
self.not_to( treat(matcher as ut_equal).unordered_columns );
243243
else
244-
self.to_( treat(matcher as ut_equal).ordered_columns );
244+
self.to_( treat(matcher as ut_equal).unordered_columns );
245245
end if;
246246
end;
247247

source/expectations/ut_expectation_compound.tps

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ create or replace type ut_expectation_compound under ut_expectation(
4949
member function join_by(a_columns ut_varchar2_list) return ut_expectation_compound,
5050
member procedure join_by(self in ut_expectation_compound, a_columns varchar2),
5151
member procedure join_by(self in ut_expectation_compound, a_columns ut_varchar2_list),
52-
member function ordered_columns return ut_expectation_compound,
53-
member procedure ordered_columns(self in ut_expectation_compound)
52+
member function unordered_columns return ut_expectation_compound,
53+
member procedure unordered_columns(self in ut_expectation_compound)
5454
)
5555
final
5656
/

test/core/expectations/test_expectations_cursor.pkb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ create or replace package body test_expectations_cursor is
300300
open l_expected for select 1 as col_1, 2 as col_2 from dual;
301301
open l_actual for select 2 as col_2, 1 as col_1 from dual;
302302
--Act
303-
ut3.ut.expect( l_actual ).to_equal( l_expected ).ordered_columns;
303+
ut3.ut.expect( l_actual ).to_equal( l_expected );
304304
--Assert
305305
ut.expect(expectations.failed_expectations_data()).not_to_be_empty();
306306
end;
@@ -314,7 +314,7 @@ create or replace package body test_expectations_cursor is
314314
open l_expected for select 1 as col_1, 2 as col_2 from dual;
315315
open l_actual for select 2 as col_2, 1 as col_1 from dual;
316316
--Act
317-
ut3.ut.expect( l_actual ).to_equal( l_expected );
317+
ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns;
318318
--Assert
319319
ut.expect(expectations.failed_expectations_data()).to_be_empty();
320320
end;
@@ -330,7 +330,7 @@ create or replace package body test_expectations_cursor is
330330
open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual;
331331
open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual;
332332
--Act
333-
ut3.ut.expect( l_actual ).to_equal( l_expected );
333+
ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered_columns;
334334
--Assert
335335
l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]
336336
%Diff:
@@ -637,7 +637,7 @@ Rows: [ 1 differences ]
637637
open l_actual for select to_char(rownum) rn, rownum another_rn from dual connect by level <=2;
638638
open l_expected for select rownum rn, rownum another_rn from dual connect by level <=2;
639639
--Act
640-
ut3.ut.expect(l_actual).to_equal(l_expected).ordered_columns;
640+
ut3.ut.expect(l_actual).to_equal(l_expected);
641641

642642
l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
643643
Diff:
@@ -682,7 +682,7 @@ Columns:%
682682
open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2;
683683
open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2;
684684
--Act
685-
ut3.ut.expect(l_actual).to_equal(l_expected).ordered_columns;
685+
ut3.ut.expect(l_actual).to_equal(l_expected);
686686

687687
l_expected_message := q'[Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
688688
Diff:
@@ -707,7 +707,7 @@ Rows: [ all different ]
707707
open l_actual for select rownum+1 col_1, rownum+2 col_2, rownum+3 col_3, rownum+4 col_4 from dual connect by level <=2;
708708
open l_expected for select rownum+1 col_1, rownum+4 col_4, rownum+2 col_2, rownum+3 col_3 from dual connect by level <=2;
709709
--Act
710-
ut3.ut.expect(l_actual).to_equal(l_expected);
710+
ut3.ut.expect(l_actual).to_equal(l_expected).unordered_columns;
711711

712712
ut.expect(expectations.failed_expectations_data()).to_be_empty();
713713
end;
@@ -791,7 +791,7 @@ Rows: [ 60 differences, showing first 20 ]
791791
select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all
792792
select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual;
793793
--Act
794-
ut3.ut.expect(l_actual).to_equal(l_expected).ordered_columns;
794+
ut3.ut.expect(l_actual).to_equal(l_expected);
795795
l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ]
796796
Diff:
797797
Columns:
@@ -828,7 +828,7 @@ Rows: [ 4 differences ]
828828
select 'F' AS GENDER, 'JESSICA' as FIRST_NAME, 'JONES' AS LAST_NAME, 4 as ID, '2345' AS SALARY from dual union all
829829
select 'M' AS GENDER, 'LUKE' as FIRST_NAME, 'SKYWALKER' AS LAST_NAME, 2 as ID, '1000' AS SALARY from dual;
830830
--Act
831-
ut3.ut.expect(l_actual).to_equal(l_expected);
831+
ut3.ut.expect(l_actual).to_equal(l_expected).unordered_columns;
832832
l_expected_message := q'[Actual: refcursor [ count = 4 ] was expected to equal: refcursor [ count = 3 ]
833833
Diff:
834834
Columns:
@@ -1051,7 +1051,7 @@ Rows: [ 4 differences ]
10511051
open l_actual for select '1' , '2' from dual connect by level <=2;
10521052
open l_expected for select rownum , rownum expected_column_name from dual connect by level <=2;
10531053
--Act
1054-
ut3.ut.expect(l_actual).to_equal(l_expected).ordered_columns;
1054+
ut3.ut.expect(l_actual).to_equal(l_expected);
10551055

10561056
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
10571057
%Diff:
@@ -1148,7 +1148,7 @@ Rows: [ 4 differences ]
11481148
open l_expected for select 1 as col_1, 2 as col_2,3 as col_3, 4 as col_4,5 col_5 from dual;
11491149
open l_actual for select 2 as col_2, 1 as col_1,40 as col_4, 5 as col_5, 30 col_3 from dual;
11501150
--Act
1151-
ut3.ut.expect( l_actual ).to_equal( l_expected ).join_by('COL_1');
1151+
ut3.ut.expect( l_actual ).to_equal( l_expected ).join_by('COL_1').unordered_columns;
11521152
--Assert
11531153
l_expected_message := q'[Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]
11541154
%Diff:

0 commit comments

Comments
 (0)