Revision 3519
Added by Aaron Marcuse-Kubitza over 12 years ago
sql_gen.py | ||
---|---|---|
133 | 133 |
|
134 | 134 |
##### Literal values |
135 | 135 |
|
136 |
#### Primitives |
|
137 |
|
|
136 | 138 |
class Literal(Code): |
137 | 139 |
def __init__(self, value): |
138 | 140 |
Code.__init__(self) |
... | ... | |
149 | 151 |
|
150 | 152 |
def is_null(value): return is_literal(value) and value.value == None |
151 | 153 |
|
154 |
#### Composites |
|
155 |
|
|
156 |
class List(Code): |
|
157 |
def __init__(self, *values): |
|
158 |
Code.__init__(self) |
|
159 |
|
|
160 |
self.values = values |
|
161 |
|
|
162 |
def to_str(self, db): |
|
163 |
return '('+(', '.join((v.to_str(db) for v in self.values)))+')' |
|
164 |
|
|
165 |
class Tuple(List): |
|
166 |
def to_str(self, db): return 'ROW'+List.to_str(self, db) |
|
167 |
|
|
152 | 168 |
##### Derived elements |
153 | 169 |
|
154 | 170 |
src_self = object() # tells Col that it is its own source column |
... | ... | |
404 | 420 |
|
405 | 421 |
def _key(self, key): return as_Col(key, self.table) |
406 | 422 |
|
407 |
##### Composite types
|
|
423 |
##### Definitions
|
|
408 | 424 |
|
409 |
class List(Code): |
|
410 |
def __init__(self, *values): |
|
411 |
Code.__init__(self) |
|
412 |
|
|
413 |
self.values = values |
|
414 |
|
|
415 |
def to_str(self, db): |
|
416 |
return '('+(', '.join((v.to_str(db) for v in self.values)))+')' |
|
417 |
|
|
418 |
class Tuple(List): |
|
419 |
def to_str(self, db): return 'ROW'+List.to_str(self, db) |
|
420 |
|
|
421 |
#### Definitions |
|
422 |
|
|
423 | 425 |
class TypedCol(Col): |
424 | 426 |
def __init__(self, name, type_, default=None, nullable=True, |
425 | 427 |
constraints=None): |
Also available in: Unified diff
sql_gen.py: Moved Composite types to Literal values section as a subsection, since Composite types was really about just the input syntaxes for these types