Project

General

Profile

« Previous | Next » 

Revision 2336

sql_gen.py: Added NamedTable. Table: Added to_Table().

View differences:

lib/sql_gen.py
36 36
        self.schema = schema
37 37
    
38 38
    def to_str(self, db): return sql.qual_name(db, self.schema, self.name)
39
    
40
    def to_Table(self): return self
39 41

  
40 42
def as_Table(table):
41 43
    if table == None or isinstance(table, Code): return table
42 44
    else: return Table(table)
43 45

  
46
class NamedTable(Table):
47
    def __init__(self, name, code, cols=None):
48
        Table.__init__(self, name)
49
        
50
        if not isinstance(code, Code): code = Table(code)
51
        
52
        self.code = code
53
        self.cols = cols
54
    
55
    def to_str(self, db):
56
        str_ = self.code.to_str(db)+' AS '+Table.to_str(self, db)
57
        if self.cols != None: str_ += ' ('+(', '.join(self.cols))+')'
58
        return str_
59
    
60
    def to_Table(self): return Table(self.name)
61

  
44 62
##### Columns
45 63

  
46 64
class Col(Code):

Also available in: Unified diff