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

Skip to content

Commit 38f3cbc

Browse files
committed
Fixed issues with comparison of dates&timestamps using interval year-month
Improved error handling for null values and incompatible datatypes Improved handling of negative dates (BC) Improved reporting of interval text value Improved datatypes to handle large&small precissions for timestamps
1 parent ed06e33 commit 38f3cbc

29 files changed

Lines changed: 312 additions & 103 deletions

docs/userguide/expectations.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,25 @@ Since NULL is neither *true* nor *false*, both expectations will report failure.
316316

317317
The matrix below illustrates the data types supported by different matchers.
318318

319-
| Matcher | blob | boolean | clob | date | number | timestamp | timestamp<br>with<br>timezone | timestamp<br>with<br>local<br>timezone | varchar2 | interval<br>year<br>to<br>month | interval<br>day<br>to<br>second | cursor | nested<br>table<br>/ varray | object | json |
320-
| :---------------------: | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | :--: |
321-
| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
322-
| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
323-
| **be_false** | | X | | | | | | | | | | | | | |
324-
| **be_true** | | X | | | | | | | | | | | | | |
325-
| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | |
326-
| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | |
327-
| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | |
328-
| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | |
329-
| **be_between** | | | | X | X | X | X | X | X | X | X | | | | |
330-
| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
331-
| **contain** | | | | | | | | | | | | X | X | X | |
332-
| **match** | | | X | | | | | | X | | | | | | |
333-
| **be_like** | | | X | | | | | | X | | | | | | |
334-
| **be_empty** | X | | X | | | | | | | | | X | X | | X |
335-
| **have_count** | | | | | | | | | | | | X | X | | X |
336-
| **be_within().of_()** | | | | x | x | | | | | | | | | | |
337-
| **be_within_pct().of()**| | | | | x | | | | | | | | | | |
319+
| Matcher | blob | boolean | clob | date | number | timestamp | timestamp<br>with<br>timezone | timestamp<br>with<br>local<br>timezone | varchar2 | interval<br>year<br>to<br>month | interval<br>day<br>to<br>second | cursor | nested<br>table<br>/ varray | object | json |
320+
| :-----------------------: | :--: | :-----: | :--: | :--: | :----: | :-------: | :---------------------------: | :------------------------------------: | :------: | :-----------------------------: | :-----------------------------: | :----: | :-------------------------: | :----: | :--: |
321+
| **be_not_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
322+
| **be_null** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
323+
| **be_false** | | X | | | | | | | | | | | | | |
324+
| **be_true** | | X | | | | | | | | | | | | | |
325+
| **be_greater_than** | | | | X | X | X | X | X | | X | X | | | | |
326+
| **be_greater_or_equal** | | | | X | X | X | X | X | | X | X | | | | |
327+
| **be_less_or_equal** | | | | X | X | X | X | X | | X | X | | | | |
328+
| **be_less_than** | | | | X | X | X | X | X | | X | X | | | | |
329+
| **be_between** | | | | X | X | X | X | X | X | X | X | | | | |
330+
| **equal** | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X |
331+
| **contain** | | | | | | | | | | | | X | X | X | |
332+
| **match** | | | X | | | | | | X | | | | | | |
333+
| **be_like** | | | X | | | | | | X | | | | | | |
334+
| **be_empty** | X | | X | | | | | | | | | X | X | | X |
335+
| **have_count** | | | | | | | | | | | | X | X | | X |
336+
| **be_within().of_()** | | | | x | x | | | | | | | | | | |
337+
| **be_within_pct().of_()** | | | | | x | | | | | | | | | | |
338338

339339
# Expecting exceptions
340340

source/core/ut_utils.pkb

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,20 @@ create or replace package body ut_utils is
919919
when l_minute > 1 then ' '||l_minute ||' minutes'
920920
end ||
921921
case
922-
when l_second = 1 then ' '||l_second ||' second'
923-
when l_second > 1 then ' '||l_second ||' seconds'
924-
end;
925-
return trim(leading ' ' from l_result);
922+
when l_second > 1 then ' '||l_second ||' seconds'
923+
when l_second = 1 then ' '||l_second ||' second'
924+
when l_second > 0 then ' '||l_second ||' seconds'
925+
end;
926+
l_result :=
927+
case
928+
when a_interval is null then 'NULL'
929+
when l_result is null then '0 seconds'
930+
else ltrim(l_result,' ')
931+
end;
932+
933+
return l_result;
926934
end;
927-
935+
928936
function interval_to_text(a_interval yminterval_unconstrained) return varchar2 is
929937
l_year varchar2(4) := extract(year from a_interval);
930938
l_month varchar2(20) := extract(month from a_interval);
@@ -935,10 +943,17 @@ create or replace package body ut_utils is
935943
when l_year > 1 then l_year ||' years'
936944
end ||
937945
case
938-
when l_month = 1 then ' '||l_month ||' month'
939-
when l_month > 1 then ' '||l_month ||' months'
940-
end;
941-
return trim(leading ' ' from l_result);
946+
when l_month > 1 then ' '||l_month ||' months'
947+
when l_month = 1 then ' '||l_month ||' month'
948+
end;
949+
l_result :=
950+
case
951+
when a_interval is null then 'NULL'
952+
when l_result is null then '0 months'
953+
else ltrim(l_result,' ')
954+
end;
955+
956+
return l_result;
942957
end;
943958

944959

source/core/ut_utils.pks

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ create or replace package ut_utils authid definer is
127127
gc_more_data_string constant varchar2(5) := '[...]';
128128
gc_more_data_string_len constant integer := length( gc_more_data_string );
129129
gc_number_format constant varchar2(100) := 'TM9';
130-
gc_date_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ss';
131-
gc_timestamp_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff';
132-
gc_timestamp_tz_format constant varchar2(100) := 'yyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm';
130+
gc_date_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ss';
131+
gc_timestamp_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff';
132+
gc_timestamp_tz_format constant varchar2(100) := 'syyyy-mm-dd"T"hh24:mi:ssxff tzh:tzm';
133133
gc_null_string constant varchar2(4) := 'NULL';
134134
gc_empty_string constant varchar2(5) := 'EMPTY';
135135

source/expectations/data_values/ut_data_value.tps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ create or replace type ut_data_value force authid current_user as object (
1616
limitations under the License.
1717
*/
1818
data_type varchar2(250 char),
19+
data_type_plsql varchar2(250 char),
1920
self_type varchar2(250 char),
2021
not instantiable member function is_null return boolean,
2122
not instantiable member function to_string return varchar2,

source/expectations/data_values/ut_data_value_blob.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_blob as
2121
self.data_value := a_value;
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'blob';
24+
self.data_type_plsql := 'blob';
2425
return;
2526
end;
2627

source/expectations/data_values/ut_data_value_boolean.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_boolean as
2121
self.data_value := ut_utils.boolean_to_int(a_value);
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'boolean';
24+
self.data_type_plsql := 'boolean';
2425
return;
2526
end;
2627

source/expectations/data_values/ut_data_value_clob.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_clob as
2121
self.data_value := a_value;
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'clob';
24+
self.data_type_plsql := 'clob';
2425
return;
2526
end;
2627

source/expectations/data_values/ut_data_value_date.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_date as
2121
self.data_value := a_value;
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'date';
24+
self.data_type_plsql := 'date';
2425
return;
2526
end;
2627

source/expectations/data_values/ut_data_value_dsinterval.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_dsinterval as
2121
self.data_value := a_value;
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'interval day to second';
24+
self.data_type_plsql := 'dsinterval_unconstrained';
2425
return;
2526
end;
2627

source/expectations/data_values/ut_data_value_number.tpb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ create or replace type body ut_data_value_number as
2121
self.data_value := a_value;
2222
self.self_type := $$plsql_unit;
2323
self.data_type := 'number';
24+
self.data_type_plsql := 'number';
2425
return;
2526
end;
2627

0 commit comments

Comments
 (0)