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 |
|
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().