Fix error unsetting season range that corresponds to existing range
This commit is contained in:
parent
2d209c8128
commit
50cc4c41b3
|
@ -13,6 +13,8 @@ declare
|
||||||
tmp_range daterange;
|
tmp_range daterange;
|
||||||
tmp_id integer;
|
tmp_id integer;
|
||||||
begin
|
begin
|
||||||
|
delete from season_calendar where range @> season_range;
|
||||||
|
|
||||||
for tmp_id, tmp_range in
|
for tmp_id, tmp_range in
|
||||||
select season_id, season_range
|
select season_id, season_range
|
||||||
from season_calendar
|
from season_calendar
|
||||||
|
@ -25,8 +27,6 @@ begin
|
||||||
;
|
;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
delete from season_calendar where range @> season_range;
|
|
||||||
|
|
||||||
update season_calendar
|
update season_calendar
|
||||||
set season_range = season_range - range
|
set season_range = season_range - range
|
||||||
where season_range && range
|
where season_range && range
|
||||||
|
|
|
@ -5,7 +5,7 @@ reset client_min_messages;
|
||||||
|
|
||||||
begin;
|
begin;
|
||||||
|
|
||||||
select plan(14);
|
select plan(15);
|
||||||
|
|
||||||
set search_path to camper, public;
|
set search_path to camper, public;
|
||||||
|
|
||||||
|
@ -47,12 +47,17 @@ values ( 9, '[2023-04-01, 2023-04-05]')
|
||||||
, (10, '[2023-04-20, 2023-04-22]')
|
, (10, '[2023-04-20, 2023-04-22]')
|
||||||
, ( 9, '[2023-04-23, 2023-04-27]')
|
, ( 9, '[2023-04-23, 2023-04-27]')
|
||||||
, ( 8, '[2023-04-28, 2023-04-30]')
|
, ( 8, '[2023-04-28, 2023-04-30]')
|
||||||
|
, ( 7, '[2023-05-01, 2023-05-31]')
|
||||||
;
|
;
|
||||||
|
|
||||||
select lives_ok($$ select unset_season_range('[2023-04-08, 2023-04-11]') $$);
|
select lives_ok($$ select unset_season_range('[2023-04-08, 2023-04-11]') $$);
|
||||||
select lives_ok($$ select unset_season_range('[2023-04-15, 2023-04-15]') $$);
|
select lives_ok($$ select unset_season_range('[2023-04-15, 2023-04-15]') $$);
|
||||||
select lives_ok($$ select unset_season_range('[2023-04-20, 2023-04-23]') $$);
|
select lives_ok($$ select unset_season_range('[2023-04-20, 2023-04-23]') $$);
|
||||||
select lives_ok($$ select unset_season_range('[2023-04-26, 2023-04-29]') $$);
|
select lives_ok($$ select unset_season_range('[2023-04-26, 2023-04-29]') $$);
|
||||||
|
select lives_ok(
|
||||||
|
$$ select unset_season_range('[2023-05-01, 2023-05-31]') $$,
|
||||||
|
'Should work if the range to unset is exactly the same as an existing range'
|
||||||
|
);
|
||||||
|
|
||||||
select bag_eq(
|
select bag_eq(
|
||||||
$$ select season_id, season_range from season_calendar $$,
|
$$ select season_id, season_range from season_calendar $$,
|
||||||
|
|
Loading…
Reference in New Issue