Project

General

Profile

« Previous | Next » 

Revision 4114

sql_gen.py: NoUnderlyingTableException: Take a (required) parameter for the item that had no underlying table, and provide this wherever a NoUnderlyingTableException is created

View differences:

lib/sql_gen.py
247 247
def is_underlying_table(table):
248 248
    return isinstance(table, Table) and table.to_Table() is table
249 249

  
250
class NoUnderlyingTableException(Exception): pass
250
class NoUnderlyingTableException(Exception):
251
    def __init__(self, ref):
252
        Exception.__init__(self, 'for: '+strings.as_tt(strings.urepr(ref)))
253
        self.ref = ref
251 254

  
252 255
def underlying_table(table):
253 256
    table = remove_table_rename(table)
254 257
    if table != None and table.srcs:
255 258
        table, = table.srcs # for derived tables or row vars
256
    if not is_underlying_table(table): raise NoUnderlyingTableException
259
    if not is_underlying_table(table): raise NoUnderlyingTableException(table)
257 260
    return table
258 261

  
259 262
def as_Table(table, schema=None):
......
407 410

  
408 411
def underlying_col(col):
409 412
    col = remove_col_rename(col)
410
    if not isinstance(col, Col): raise NoUnderlyingTableException
413
    if not isinstance(col, Col): raise NoUnderlyingTableException(col)
411 414
    
412 415
    return Col(col.name, underlying_table(col.table), col.srcs)
413 416

  
lib/sql.py
477 477
        cur = select(self, table, cols, conds, order_by='table_schema', limit=1,
478 478
            cacheable=cacheable, log_level=4) # TODO: order by search_path order
479 479
        try: type_, default, nullable = row(cur)
480
        except StopIteration: raise sql_gen.NoUnderlyingTableException
480
        except StopIteration: raise sql_gen.NoUnderlyingTableException(col)
481 481
        default = sql_gen.as_Code(default, self)
482 482
        
483 483
        return sql_gen.TypedCol(col.name, type_, default, nullable)

Also available in: Unified diff