Revision 3429
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
130 | 130 |
if isinstance(value, Code): return value |
131 | 131 |
else: return Literal(value) |
132 | 132 |
|
133 |
def is_null(value): return isinstance(value, Literal) and value.value == None
|
|
133 |
def is_literal(value): return isinstance(value, Literal)
|
|
134 | 134 |
|
135 |
def is_null(value): return is_literal(value) and value.value == None |
|
136 |
|
|
135 | 137 |
##### Derived elements |
136 | 138 |
|
137 | 139 |
src_self = object() # tells Col that it is its own source column |
... | ... | |
437 | 439 |
return 'CAST('+self.value.to_str(db)+' AS '+self.type_+')' |
438 | 440 |
|
439 | 441 |
def cast_literal(value): |
440 |
if not isinstance(value, Literal): return value
|
|
442 |
if not is_literal(value): return value
|
|
441 | 443 |
|
442 | 444 |
if util.is_str(value.value): value = Cast('text', value) |
443 | 445 |
return value |
... | ... | |
725 | 727 |
try: typed_col = db.col_info(underlying_col(col)) |
726 | 728 |
except NoUnderlyingTableException: |
727 | 729 |
col = remove_col_rename(col) |
728 |
if isinstance(col, Literal) and not is_null(col): nullable = False
|
|
730 |
if is_literal(col) and not is_null(col): nullable = False
|
|
729 | 731 |
elif type_ == None: raise |
730 | 732 |
else: |
731 | 733 |
if type_ == None: type_ = typed_col.type |
Also available in: Unified diff
sql_gen.py: Added is_literal() and use it where isinstance(..., Literal) is used