def expand_column_list_from_order_by(collist, order_by):
 cols_already_present = set([(col.element if (col._order_by_label_element is not None) else col) for col in collist])
 return [col for col in chain(*[unwrap_order_by(o) for o in order_by]) if (col not in cols_already_present)]

def expand_column_list_from_order_by ( collist , order_by ) : cols_already_present = set ( [ ( col . element if ( col . _order_by_label_element is not None ) else col ) for col in collist ] ) return [ col for col in chain ( * [ unwrap_order_by ( o ) for o in order_by ] ) if ( col not in cols_already_present ) ]
given the columns clause and order by of a selectable .