Project

General

Profile

« Previous | Next » 

Revision 3445

sql_gen.py: Fixed bug where Code subclasses needed to call Code.__init__() in their init() function. BasicObject: Fixed bug where init() expected a value param, when in fact the value param is something added by certain subclasses.

View differences:

sql_gen.py
75 75
mockDb = MockDb()
76 76

  
77 77
class BasicObject(objects.BasicObject):
78
    def __init__(self, value): self.value = value
79
    
80 78
    def __str__(self): return clean_name(strings.repr_no_u(self))
81 79

  
82 80
##### Unparameterized code objects
83 81

  
84 82
class Code(BasicObject):
83
    def __init__(self): pass
84
    
85 85
    def to_str(self, db): raise NotImplementedError()
86 86
    
87 87
    def __repr__(self): return self.to_str(mockDb)
88 88

  
89 89
class CustomCode(Code):
90
    def __init__(self, str_): self.str_ = str_
90
    def __init__(self, str_):
91
        Code.__init__(self)
92
        
93
        self.str_ = str_
91 94
    
92 95
    def to_str(self, db): return self.str_
93 96

  
......
101 104
    else: return Literal(value)
102 105

  
103 106
class Expr(Code):
104
    def __init__(self, expr): self.expr = expr
107
    def __init__(self, expr):
108
        Code.__init__(self)
109
        
110
        self.expr = expr
105 111
    
106 112
    def to_str(self, db): return '('+self.expr.to_str(db)+')'
107 113

  
......
109 115

  
110 116
class Name(Code):
111 117
    def __init__(self, name):
118
        Code.__init__(self)
119
        
112 120
        name = truncate(name)
113 121
        
114 122
        self.name = name
......
122 130
##### Literal values
123 131

  
124 132
class Literal(Code):
125
    def __init__(self, value): self.value = value
133
    def __init__(self, value):
134
        Code.__init__(self)
135
        
136
        self.value = value
126 137
    
127 138
    def to_str(self, db): return db.esc_value(self.value)
128 139

  
......
143 154
        '''An element which was derived from some other element(s).
144 155
        @param srcs See self.set_srcs()
145 156
        '''
157
        Code.__init__(self)
158
        
146 159
        self.set_srcs(srcs)
147 160
    
148 161
    def set_srcs(self, srcs, overwrite=True):
......
398 411
        '''
399 412
        @param args [Code|literal-value...] The function's arguments
400 413
        '''
414
        Code.__init__(self)
415
        
401 416
        function = as_Function(function)
402 417
        def filter_(arg): return remove_col_rename(as_Value(arg))
403 418
        args = map(filter_, args)
......
432 447

  
433 448
class FunctionDef(Code):
434 449
    def __init__(self, function, return_type, body, lang='sql'):
450
        Code.__init__(self)
451
        
435 452
        body = as_Code(body)
436 453
        
437 454
        self.function = function
......
472 489

  
473 490
class NotCond(Code):
474 491
    def __init__(self, cond):
492
        Code.__init__(self)
493
        
475 494
        self.cond = cond
476 495
    
477 496
    def to_str(self, db): return 'NOT '+self.cond.to_str(db)
478 497

  
479 498
class ColValueCond(Code):
480 499
    def __init__(self, col, value):
500
        Code.__init__(self)
501
        
481 502
        value = as_ValueCond(value)
482 503
        
483 504
        self.col = col
......
693 714
        '''
694 715
        @param values [...]|[[...], ...] Can be one or multiple rows.
695 716
        '''
717
        Code.__init__(self)
718
        
696 719
        rows = values
697 720
        if len(values) >= 1 and not lists.is_seq(values[0]): # only one row
698 721
            rows = [values]

Also available in: Unified diff