Revision 2161
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
380 | 380 |
|
381 | 381 |
params = [] |
382 | 382 |
|
383 |
def parse_col(field): |
|
383 |
def parse_col(field, default_table=None):
|
|
384 | 384 |
'''Parses fields''' |
385 | 385 |
is_tuple = isinstance(field, tuple) |
386 | 386 |
if is_tuple and len(field) == 1: # field is literal value |
... | ... | |
391 | 391 |
table, col = field |
392 | 392 |
if not table_is_esc: table = esc_name_(table) |
393 | 393 |
sql_ = table+'.'+esc_name_(col) |
394 |
else: sql_ = esc_name_(field) # field is col name |
|
394 |
else: |
|
395 |
sql_ = esc_name_(field) # field is col name |
|
396 |
if default_table != None: sql_ = default_table+'.'+sql_ |
|
395 | 397 |
return sql_ |
396 | 398 |
def cond(entry): |
397 | 399 |
'''Parses conditions''' |
... | ... | |
417 | 419 |
'''Parses non-USING joins''' |
418 | 420 |
right_col, left_col = entry |
419 | 421 |
right_col = table+'.'+esc_name_(right_col) |
420 |
left_col = left_table+'.'+esc_name_(left_col)
|
|
422 |
left_col = parse_col(left_col, left_table)
|
|
421 | 423 |
return (right_col+' = '+left_col |
422 | 424 |
+' OR ('+right_col+' IS NULL AND '+left_col+' IS NULL)') |
423 | 425 |
|
Also available in: Unified diff
sql.py: mk_select(): Parse join columns for literal values and table-scoped names as well