Skip to content

Commit

Permalink
unformat
Browse files Browse the repository at this point in the history
  • Loading branch information
ppKrauss committed Aug 6, 2018
1 parent d0c2f7d commit 4e51a3a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/osmWd_raw-transform.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ CREATE FUNCTION wdosm.wd_id_format( p_ids JSONb ) RETURNS text AS $f$
FROM jsonb_each_text($1)
$f$ language SQL IMMUTABLE;

CREATE FUNCTION wdosm.wd_id_unformat( p_list text ) RETURNS JSONb AS $f$
-- reverts wdosm.wd_id_format()
SELECT jsonb_object_agg(substr(x[1],2), x[2]::int)
FROM (
SELECT regexp_split_to_array(item, ':') as x
FROM regexp_split_to_table($1, '[\s,;\|]+') t2(item)
) t
$f$ language SQL IMMUTABLE;

---------------
--- ALGORITMO:
Expand Down

0 comments on commit 4e51a3a

Please sign in to comment.