Revision 2124
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
310 | 310 |
order_by=order_by_pkey, table_is_esc=False): |
311 | 311 |
''' |
312 | 312 |
@param tables The single table to select from, or a list of tables to join |
313 |
together, in the form: [table0, (table1, joins_dict), ...]
|
|
313 |
together: [table0, (table1, dict(right_col=left_col, ...)), ...]
|
|
314 | 314 |
@param fields Use None to select all fields in the table |
315 | 315 |
@param table_is_esc Whether the table name has already been escaped |
316 | 316 |
@return tuple(query, params) |
... | ... | |
360 | 360 |
|
361 | 361 |
def join(entry): |
362 | 362 |
'''Parses joins''' |
363 |
left_col, right_col = entry |
|
363 |
right_col, left_col = entry |
|
364 |
right_col = table+'.'+esc_name_(right_col) |
|
364 | 365 |
left_col = left_table+'.'+esc_name_(left_col) |
365 |
right_col = table+'.'+esc_name_(right_col) |
|
366 | 366 |
return (right_col+' = '+left_col |
367 | 367 |
+' OR ('+right_col+' IS NULL AND '+left_col+' IS NULL)') |
368 | 368 |
|
Also available in: Unified diff
sql.py: mk_select(): Joins: Reversed order of left_col and right_col in the joins dict as well, so the joined table's columns are the keys