diff --git a/client/cdb_dataservices_client--0.25.0.sql b/client/cdb_dataservices_client--0.25.0.sql index af58ce2..b69a536 100644 --- a/client/cdb_dataservices_client--0.25.0.sql +++ b/client/cdb_dataservices_client--0.25.0.sql @@ -18,7 +18,12 @@ BEGIN RETURN ROWS; END -$func$ LANGUAGE plpgsql;-- +$func$ LANGUAGE plpgsql; + +-- Taken from https://stackoverflow.com/a/48013356/351721 +CREATE OR REPLACE FUNCTION jsonb_array_casttext(jsonb) RETURNS text[] AS $f$ + SELECT array_agg(x) || ARRAY[]::text[] FROM jsonb_array_elements_text($1) t(x); +$f$ LANGUAGE sql IMMUTABLE;-- -- Geocoder server connection config -- -- The purpose of this function is provide to the PL/Proxy functions diff --git a/client/sql/05_utils.sql b/client/sql/05_utils.sql index d161c6a..31c8445 100644 --- a/client/sql/05_utils.sql +++ b/client/sql/05_utils.sql @@ -12,4 +12,9 @@ BEGIN RETURN ROWS; END -$func$ LANGUAGE plpgsql; \ No newline at end of file +$func$ LANGUAGE plpgsql; + +-- Taken from https://stackoverflow.com/a/48013356/351721 +CREATE OR REPLACE FUNCTION jsonb_array_casttext(jsonb) RETURNS text[] AS $f$ + SELECT array_agg(x) || ARRAY[]::text[] FROM jsonb_array_elements_text($1) t(x); +$f$ LANGUAGE sql IMMUTABLE; \ No newline at end of file