Revision 2213
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
class Literal: |
9 | 9 |
def __init__(self, value): self.value = value |
10 |
|
|
11 |
def to_str(self, db): return db.esc_value(self.value) |
|
10 | 12 |
|
11 | 13 |
class Table(Code): |
12 | 14 |
def __init__(self, name, schema=None): |
... | ... | |
35 | 37 |
return str_ |
36 | 38 |
|
37 | 39 |
class ValueCond(Code): |
38 |
def __init__(self, value): self.value = value |
|
40 |
def __init__(self, value): |
|
41 |
if not isinstance(value, Literal): value = Literal(value) |
|
42 |
|
|
43 |
self.value = value |
|
39 | 44 |
|
40 | 45 |
class CompareCond(ValueCond): |
41 | 46 |
def __init__(self, value, operator='='): |
42 | 47 |
ValueCond.__init__(self, value) |
43 | 48 |
self.operator = operator |
44 | 49 |
|
45 |
def to_str(self, db): |
|
46 |
raise NotImplemented() |
|
50 |
def to_str(self, db): return self.operator+' '+self.value.to_str(db) |
Also available in: Unified diff
sql_gen.py: Literal, CompareCond: Implemented to_str(). ValueCond: Autoconvert literal values to Literals.