Revision 2173
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
428 | 428 |
'''Parses non-USING joins''' |
429 | 429 |
right_col, left_col = entry |
430 | 430 |
right_col = table+'.'+esc_name_(right_col) |
431 |
left_col = parse_col(left_col, left_table) |
|
432 |
return (right_col+' = '+left_col |
|
433 |
+' OR ('+right_col+' IS NULL AND '+left_col+' IS NULL)') |
|
431 |
sql_ = right_col+' ' |
|
432 |
|
|
433 |
if isinstance(left_col, tuple) and len(left_col) == 1: |
|
434 |
# col is literal value |
|
435 |
value, = left_col |
|
436 |
if value == None: sql_ += 'IS' |
|
437 |
else: sql_ += '=' |
|
438 |
sql_ += ' %s' |
|
439 |
params.append(value) |
|
440 |
else: # col is name |
|
441 |
left_col = parse_col(left_col, left_table) |
|
442 |
sql_ += ('= '+left_col+' OR ('+right_col+' IS NULL AND ' |
|
443 |
+left_col+' IS NULL)') |
|
444 |
|
|
445 |
return sql_ |
|
434 | 446 |
|
435 | 447 |
if reduce(operator.and_, (v == join_using for v in joins.itervalues())): |
436 | 448 |
# all cols w/ USING |
Also available in: Unified diff
mk_select(): Support join conditions with literal values