Revision 4936
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
466 | 466 |
|
467 | 467 |
def col_info(self, col, cacheable=True): |
468 | 468 |
table = sql_gen.Table('columns', 'information_schema') |
469 |
type_ = sql_gen.Coalesce(sql_gen.Nullif(sql_gen.Col('data_type'), |
|
470 |
'USER-DEFINED'), sql_gen.Col('udt_name')) |
|
471 |
cols = [type_, 'column_default', |
|
472 |
sql_gen.Cast('boolean', sql_gen.Col('is_nullable'))] |
|
469 |
cols = [sql_gen.Col('data_type'), sql_gen.Col('udt_name'), |
|
470 |
'column_default', sql_gen.Cast('boolean', |
|
471 |
sql_gen.Col('is_nullable'))] |
|
473 | 472 |
|
474 | 473 |
conds = [('table_name', col.table.name), |
475 | 474 |
('column_name', strings.ustr(col.name))] |
... | ... | |
478 | 477 |
|
479 | 478 |
cur = select(self, table, cols, conds, order_by='table_schema', limit=1, |
480 | 479 |
cacheable=cacheable, log_level=4) # TODO: order by search_path order |
481 |
try: type_, default, nullable = row(cur) |
|
480 |
try: type_, extra_type, default, nullable = row(cur)
|
|
482 | 481 |
except StopIteration: raise sql_gen.NoUnderlyingTableException(col) |
483 | 482 |
default = sql_gen.as_Code(default, self) |
483 |
if type_ == 'USER-DEFINED': type_ = extra_type |
|
484 | 484 |
|
485 | 485 |
return sql_gen.TypedCol(col.name, type_, default, nullable) |
486 | 486 |
|
Also available in: Unified diff
sql.py: DbConn.col_info(): Moved parsing of user-defined datatypes to Python code, so that parsing for other composite types which also requires both data_type and udt_name can easily be added