Revision 4009
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/functions.sql | ||
---|---|---|
126 | 126 |
CREATE FUNCTION join_strs_transform_fold_empty(state text, delim text, value text) RETURNS text |
127 | 127 |
LANGUAGE sql IMMUTABLE |
128 | 128 |
AS $_$ |
129 |
SELECT functions.join_strs_transform_preserve_empty($1, $2, NULLIF($3, '')) |
|
130 |
$_$; |
|
131 |
|
|
132 |
|
|
133 |
-- |
|
134 |
-- Name: join_strs_transform_preserve_empty(text, text, text); Type: FUNCTION; Schema: functions; Owner: - |
|
135 |
-- |
|
136 |
|
|
137 |
CREATE FUNCTION join_strs_transform_preserve_empty(state text, delim text, value text) RETURNS text |
|
138 |
LANGUAGE sql IMMUTABLE |
|
139 |
AS $_$ |
|
129 | 140 |
SELECT $1 || (CASE |
130 |
WHEN $1 = '' OR $3 IS NULL OR $3 = ''
|
|
141 |
WHEN $1 = '' OR $3 IS NULL |
|
131 | 142 |
THEN '' |
132 | 143 |
ELSE $2 |
133 | 144 |
END) || coalesce($3, ''); |
Also available in: Unified diff
schemas/functions.sql: Added join_strs_transform_preserve_empty() and use it in join_strs_transform_fold_empty()