Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Commit

Permalink
Add delete_empty_keys function
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Jun 1, 2017
1 parent faed18e commit 2117e48
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions language.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ BEGIN
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;


CREATE OR REPLACE FUNCTION delete_empty_keys(tags hstore) RETURNS hstore AS $$
DECLARE
result hstore;
BEGIN
select
hstore(array_agg(key), array_agg(value)) into result
from
each(hstore(tags))
where nullif(value, '') is not null;
RETURN result;
END;
$$ STRICT
LANGUAGE plpgsql IMMUTABLE;

0 comments on commit 2117e48

Please sign in to comment.