447 |
447 |
if conds == None: conds = {}
|
448 |
448 |
assert limit == None or type(limit) == int
|
449 |
449 |
assert start == None or type(start) == int
|
450 |
|
if order_by == order_by_pkey:
|
|
450 |
if order_by is order_by_pkey:
|
451 |
451 |
order_by = pkey(db, table0, recover=True, table_is_esc=table_is_esc)
|
452 |
452 |
if not table_is_esc: table0 = esc_name_(table0)
|
453 |
453 |
|
... | ... | |
467 |
467 |
# DISTINCT ON columns
|
468 |
468 |
if distinct_on != []:
|
469 |
469 |
query += ' DISTINCT'
|
470 |
|
if distinct_on != distinct_on_all:
|
|
470 |
if distinct_on is not distinct_on_all:
|
471 |
471 |
query += ' ON ('+(', '.join(map(parse_col, distinct_on)))+')'
|
472 |
472 |
|
473 |
473 |
# Columns
|
... | ... | |
487 |
487 |
|
488 |
488 |
# Parse special values
|
489 |
489 |
for right, left in joins.items():
|
490 |
|
if left == filter_out:
|
|
490 |
if left is filter_out:
|
491 |
491 |
left_join = True
|
492 |
492 |
# Can't use join_using because the columns being joined can have
|
493 |
493 |
# different values in a LEFT JOIN.
|
... | ... | |
503 |
503 |
# Parse special values
|
504 |
504 |
if left_col == None: left_col = (left_col,)
|
505 |
505 |
# for None values, tuple is optional
|
506 |
|
elif left_col == join_using: left_col = right_col
|
|
506 |
elif left_col is join_using: left_col = right_col
|
507 |
507 |
|
508 |
508 |
return cond((sql_gen.col2sql_gen(right_col, table, table_is_esc),
|
509 |
509 |
sql_gen.cond2sql_gen(left_col, left_table, table_is_esc,
|
510 |
510 |
assume_col=True)))
|
511 |
511 |
|
512 |
512 |
# Create join condition and determine join type
|
513 |
|
if reduce(operator.and_, (v == join_using for v in joins.itervalues())):
|
|
513 |
if reduce(operator.and_, (v is join_using for v in joins.itervalues())):
|
514 |
514 |
# all cols w/ USING, so can use simpler USING syntax
|
515 |
515 |
join_cond = 'USING ('+(', '.join(joins.iterkeys()))+')'
|
516 |
516 |
else: join_cond = 'ON '+(' AND '.join(map(join, joins.iteritems())))
|
... | ... | |
623 |
623 |
labels = []
|
624 |
624 |
values = []
|
625 |
625 |
for value in row:
|
626 |
|
if value == default: labels.append('DEFAULT')
|
|
626 |
if value is default: labels.append('DEFAULT')
|
627 |
627 |
else:
|
628 |
628 |
labels.append('%s')
|
629 |
629 |
values.append(value)
|
Compare object()-based sentinel values using is. Where sentinel values must be compared using ==, use rand.rand_int() instead.