Project

General

Profile

« Previous | Next » 

Revision 2233

sql.py: mk_select(): distinct_on is turned off when distinct_on == [] rather than when it's None

View differences:

lib/sql.py
399 399

  
400 400
distinct_on_all = object() # tells mk_select() to SELECT DISTINCT ON all columns
401 401

  
402
def mk_select(db, tables, fields=None, conds=None, distinct_on=None, limit=None,
402
def mk_select(db, tables, fields=None, conds=None, distinct_on=[], limit=None,
403 403
    start=None, order_by=order_by_pkey, table_is_esc=False, default_table=None):
404 404
    '''
405 405
    @param tables The single table to select from, or a list of tables to join
......
445 445
    query = 'SELECT'
446 446
    
447 447
    # DISTINCT ON columns
448
    if distinct_on != None:
448
    if distinct_on != []:
449 449
        query += ' DISTINCT'
450 450
        if distinct_on != distinct_on_all:
451 451
            query += ' ON ('+(', '.join(map(parse_col, distinct_on)))+')'
......
773 773
            pkeys_table_exists_ref[0] = True
774 774
    
775 775
    conds = {}
776
    distinct_on = None
776
    distinct_on = []
777 777
    def mk_main_select(cols):
778 778
        return mk_select(db, insert_joins, cols, conds, distinct_on,
779 779
            order_by=None, limit=limit, start=start, table_is_esc=table_is_esc,

Also available in: Unified diff