Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EXDATE and RDATE parsing to to rruleset (TEXT) function #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions postgres-rrule.sql
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,16 @@ CREATE OR REPLACE FUNCTION _rrule.rruleset (TEXT)
RETURNS _rrule.RRULESET AS $$
WITH "dtstart-line" AS (SELECT _rrule.parse_line($1::text, 'DTSTART') as "x"),
"dtend-line" AS (SELECT _rrule.parse_line($1::text, 'DTEND') as "x"),
"exrule-line" AS (SELECT _rrule.parse_line($1::text, 'EXRULE') as "x")
"exrule-line" AS (SELECT _rrule.parse_line($1::text, 'EXRULE') as "x"),
"rdate-line" AS (SELECT _rrule.parse_line($1::text, 'RDATE') as "x"),
"exdate-line" AS (SELECT _rrule.parse_line($1::text, 'EXDATE') as "x")
SELECT
(SELECT "x"::timestamp FROM "dtstart-line" LIMIT 1) AS "dtstart",
(SELECT "x"::timestamp FROM "dtend-line" LIMIT 1) AS "dtend",
(SELECT _rrule.rrule($1::text) "rrule") as "rrule",
(SELECT _rrule.rrule("x"::text) "rrule" FROM "exrule-line") as "exrule",
NULL::TIMESTAMP[] "rdate",
NULL::TIMESTAMP[] "exdate";
(SELECT (regexp_split_to_array("x"::text, ','))::TIMESTAMP[] from "rdate-line" AS "rdate"),
(SELECT (regexp_split_to_array("x"::text, ','))::TIMESTAMP[] from "exdate-line" AS "exdate");
$$ LANGUAGE SQL IMMUTABLE STRICT;

-- All of the function(rrule, ...) forms also accept a text argument, which will
Expand Down Expand Up @@ -983,4 +985,3 @@ CREATE CAST (jsonb AS _rrule.RRULE)
CREATE CAST (_rrule.RRULE AS jsonb)
WITH FUNCTION _rrule.rrule_to_jsonb(_rrule.RRULE)
AS IMPLICIT;

9 changes: 5 additions & 4 deletions src/functions/0105-rruleset.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ CREATE OR REPLACE FUNCTION _rrule.rruleset (TEXT)
RETURNS _rrule.RRULESET AS $$
WITH "dtstart-line" AS (SELECT _rrule.parse_line($1::text, 'DTSTART') as "x"),
"dtend-line" AS (SELECT _rrule.parse_line($1::text, 'DTEND') as "x"),
"exrule-line" AS (SELECT _rrule.parse_line($1::text, 'EXRULE') as "x")
"exrule-line" AS (SELECT _rrule.parse_line($1::text, 'EXRULE') as "x"),
"rdate-line" AS (SELECT _rrule.parse_line($1::text, 'RDATE') as "x"),
"exdate-line" AS (SELECT _rrule.parse_line($1::text, 'EXDATE') as "x")
SELECT
(SELECT "x"::timestamp FROM "dtstart-line" LIMIT 1) AS "dtstart",
(SELECT "x"::timestamp FROM "dtend-line" LIMIT 1) AS "dtend",
(SELECT _rrule.rrule($1::text) "rrule") as "rrule",
(SELECT _rrule.rrule("x"::text) "rrule" FROM "exrule-line") as "exrule",
NULL::TIMESTAMP[] "rdate",
NULL::TIMESTAMP[] "exdate";
(SELECT (regexp_split_to_array("x"::text, ','))::TIMESTAMP[] from "rdate-line" AS "rdate"),
(SELECT (regexp_split_to_array("x"::text, ','))::TIMESTAMP[] from "exdate-line" AS "exdate");
$$ LANGUAGE SQL IMMUTABLE STRICT;