Project

General

Profile

« Previous | Next » 

Revision 10842

lib/sql_gen.py: Join: added custom_cond param that can be used to add to the JOIN condition

View differences:

sql_gen.py
919 919
filter_out = object() # tells Join to filter out rows that match the join
920 920

  
921 921
class Join(BasicObject):
922
    def __init__(self, table, mapping={}, type_=None):
922
    def __init__(self, table, mapping={}, type_=None, custom_cond=None):
923 923
        '''
924 924
        @param mapping dict(right_table_col=left_table_col, ...)
925 925
            or [using_col...]
......
940 940
        self.table = table
941 941
        self.mapping = mapping
942 942
        self.type_ = type_
943
        self.custom_cond = custom_cond
943 944
    
944 945
    def to_str(self, db, left_table_):
945 946
        def join(entry):
......
986 987
        if type_ != None: str_ += type_+' '
987 988
        str_ += 'JOIN'+whitespace+self.table.to_str(db)
988 989
        if join_cond != None: str_ += whitespace+join_cond
990
        if self.custom_cond != None: str_ += '\nAND '+self.custom_cond
989 991
        return str_
990 992
    
991 993
    def __repr__(self): return self.to_str(mockDb, '<left_table>')

Also available in: Unified diff