Project

General

Profile

« Previous | Next » 

Revision 4983

schemas/py_functions.sql: _namePart(): Fixed bug where it was returning the empty string instead of NULL

View differences:

schemas/py_functions.sql
177 177
    AS $$
178 178
params = dict(first=first, middle=middle, last=last)
179 179

  
180
def none_if(val, *none_vals):
181
    for none_val in none_vals:
182
        if val == none_val: return None
183
    return val
184

  
180 185
_name_parts_slices_items = [
181 186
    ('first', slice(None, -1)),
182 187
    ('middle', slice(1, -1)),
......
190 195
    parts = []
191 196
    for part in name_parts:
192 197
        if part in items: parts.append(items[part])
193
    return ' '.join(parts)
198
    return none_if(' '.join(parts), '')
194 199

  
195 200
out_items = []
196 201
for part, value in params.iteritems():

Also available in: Unified diff