Project

General

Profile

« Previous | Next » 

Revision 2199

sql.py: mk_select(): Added distinct_on param to set the columns to SELECT DISTINCT ON

View differences:

lib/sql.py
387 387

  
388 388
filter_out = object() # tells mk_select() to filter out rows that match the join
389 389

  
390
def mk_select(db, tables, fields=None, conds=None, limit=None, start=None,
391
    order_by=order_by_pkey, table_is_esc=False):
390
distinct_on_all = object() # tells mk_select() to SELECT DISTINCT ON all columns
391

  
392
def mk_select(db, tables, fields=None, conds=None, distinct_on=None, limit=None,
393
    start=None, order_by=order_by_pkey, table_is_esc=False):
392 394
    '''
393 395
    @param tables The single table to select from, or a list of tables to join
394 396
        together: [table0, (table1, joins), ...]
......
398 400
        * if left_col is filter_out, the tables are LEFT JOINed together and the
399 401
          query is filtered by `right_col IS NULL` (indicating no match)
400 402
    @param fields Use None to select all fields in the table
403
    @param distinct_on The columns to SELECT DISTINCT ON, or distinct_on_all to
404
        use all columns
401 405
    @param table_is_esc Whether the table name has already been escaped
402 406
    @return tuple(query, params)
403 407
    '''

Also available in: Unified diff