Skip to content

Commit

Permalink
fix: allow empty strings in datetime intervals (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski authored Feb 6, 2023
1 parent 6422105 commit f42e233
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/002b_cql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ BEGIN
RAISE EXCEPTION 'Timestamp cannot have more than 2 values';
END IF;

IF timestrs[1] = '..' THEN
IF timestrs[1] = '..' OR timestrs[1] = '' THEN
s := '-infinity'::timestamptz;
e := timestrs[2]::timestamptz;
RETURN tstzrange(s,e,'[)');
END IF;

IF timestrs[2] = '..' THEN
IF timestrs[2] = '..' OR timestrs[2] = '' THEN
s := timestrs[1]::timestamptz;
e := 'infinity'::timestamptz;
RETURN tstzrange(s,e,'[)');
Expand Down
12 changes: 12 additions & 0 deletions test/pgtap/004_search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ SELECT results_eq($$ SELECT parse_dtrange('["2020-01-01","2021-01-01"]'::jsonb)
SELECT results_eq($$ SELECT parse_dtrange('"2020-01-01/2021-01-01"'::jsonb) $$, $$ SELECT '["2020-01-01 00:00:00+00","2021-01-01 00:00:00+00")'::tstzrange $$, 'date range passed as string range');


SELECT results_eq($$ SELECT parse_dtrange('"2020-01-01/.."'::jsonb) $$, $$ SELECT '["2020-01-01 00:00:00+00",infinity)'::tstzrange $$, 'date range passed as string range');


SELECT results_eq($$ SELECT parse_dtrange('"2020-01-01/"'::jsonb) $$, $$ SELECT '["2020-01-01 00:00:00+00",infinity)'::tstzrange $$, 'date range passed as string range');


SELECT results_eq($$ SELECT parse_dtrange('"../2020-01-01"'::jsonb) $$, $$ SELECT '[-infinity,"2020-01-01 00:00:00+00")'::tstzrange $$, 'date range passed as string range');


SELECT results_eq($$ SELECT parse_dtrange('"/2020-01-01"'::jsonb) $$, $$ SELECT '[-infinity,"2020-01-01 00:00:00+00")'::tstzrange $$, 'date range passed as string range');


SELECT has_function('pgstac'::name, 'bbox_geom', ARRAY['jsonb']);


Expand Down

0 comments on commit f42e233

Please sign in to comment.