Revision 4010
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/functions.sql | ||
---|---|---|
137 | 137 |
CREATE FUNCTION join_strs_transform_preserve_empty(state text, delim text, value text) RETURNS text |
138 | 138 |
LANGUAGE sql IMMUTABLE |
139 | 139 |
AS $_$ |
140 |
SELECT $1 || (CASE
|
|
141 |
WHEN $1 = '' OR $3 IS NULL
|
|
142 |
THEN ''
|
|
143 |
ELSE $2
|
|
144 |
END) || coalesce($3, '');
|
|
140 |
SELECT (CASE |
|
141 |
WHEN $1 IS NOT NULL AND $3 IS NOT NULL
|
|
142 |
THEN $1 || $2 || $3
|
|
143 |
ELSE COALESCE($1, $3)
|
|
144 |
END)
|
|
145 | 145 |
$_$; |
146 | 146 |
|
147 | 147 |
|
... | ... | |
151 | 151 |
|
152 | 152 |
CREATE AGGREGATE join_strs(text, text) ( |
153 | 153 |
SFUNC = join_strs_transform_fold_empty, |
154 |
STYPE = text, |
|
155 |
INITCOND = '' |
|
154 |
STYPE = text |
|
156 | 155 |
); |
157 | 156 |
|
158 | 157 |
|
Also available in: Unified diff
schemas/functions.sql: join_strs(): Return NULL if all strings were NULL or ''. This fixes unexpected behavior in _merge() where all elements are NULL but the return value is non-NULL.