Project

General

Profile

« Previous | Next » 

Revision 2514

sql_gen.py: sql_gen classes inherit from new base class BasicObject, whose str() calls clean_name() on the object's repr(). Changed the main debug-repr producing method to be repr() instead of str().

View differences:

lib/sql_gen.py
22 22
    def esc_name(self, name): return esc_name(name)
23 23
mockDb = MockDb()
24 24

  
25
class Code(objects.BasicObject):
25
class BasicObject(objects.BasicObject):
26
    def __init__(self, value): self.value = value
27
    
28
    def __str__(self): return clean_name(strings.repr_no_u(self))
29

  
30
class Code(BasicObject):
26 31
    def to_str(self, db): raise NotImplemented()
27 32
    
28
    def __str__(self): return self.to_str(mockDb)
33
    def __repr__(self): return self.to_str(mockDb)
29 34

  
30 35
class CustomCode(Code):
31 36
    def __init__(self, str_): self.str_ = str_
......
150 155

  
151 156
##### Condition column comparisons
152 157

  
153
class ValueCond(objects.BasicObject):
158
class ValueCond(BasicObject):
154 159
    def __init__(self, value):
155 160
        if not isinstance(value, Code): value = Literal(value)
156 161
        value = remove_col_rename(value)
......
163 168
        '''
164 169
        raise NotImplemented()
165 170
    
166
    def __str__(self): return self.to_str(mockDb, '<left_value>')
171
    def __repr__(self): return self.to_str(mockDb, '<left_value>')
167 172

  
168 173
class CompareCond(ValueCond):
169 174
    def __init__(self, value, operator='='):
......
217 222

  
218 223
filter_out = object() # tells Join to filter out rows that match the join
219 224

  
220
class Join(objects.BasicObject):
225
class Join(BasicObject):
221 226
    def __init__(self, table, mapping, type_=None):
222 227
        '''
223 228
        @param mapping dict(right_table_col=left_table_col, ...)
......
275 280
        str_ += 'JOIN '+left_table.to_str(db)+' '+join_cond
276 281
        return str_
277 282
    
278
    def __str__(self): return self.to_str(mockDb, '<left_table>')
283
    def __repr__(self): return self.to_str(mockDb, '<left_table>')
279 284

  
280 285
##### Value exprs
281 286

  
lib/sql.py
882 882
    
883 883
    def log_debug(msg): db.log_debug(msg, level=1.5)
884 884
    def col_ustr(str_):
885
        return strings.ustr(sql_gen.remove_col_rename(sql_gen.as_Col(str_)))
885
        return strings.repr_no_u(sql_gen.remove_col_rename(
886
            sql_gen.as_Col(str_)))
886 887
    
887 888
    log_debug('********** New iteration **********')
888 889
    log_debug('Inserting these input columns into '+strings.as_tt(
......
942 943
        log_debug('Returning NULL for all rows')
943 944
        limit_ref[0] = 0 # just create an empty pkeys table
944 945
    def ignore(in_col, value):
945
        in_col_str = str(in_col)
946
        in_col_str = repr(in_col)
946 947
        log_debug('Adding index on '+in_col_str+' to enable fast filtering')
947 948
        index_col(db, in_col)
948 949
        log_debug('Ignoring rows with '+in_col_str+' = '+repr(value))

Also available in: Unified diff