Project

General

Profile

« Previous | Next » 

Revision 2739

sql_gen.py: Values: Support multiple rows

View differences:

lib/sql_gen.py
466 466

  
467 467
class Values(Code):
468 468
    def __init__(self, values):
469
        values = map(remove_col_rename, map(as_Value, values))
469
        '''
470
        @param values [...]|[[...], ...] Can be one or multiple rows.
471
        '''
472
        rows = values
473
        if len(values) >= 1 and not lists.is_seq(values[0]): # only one row
474
            rows = [values]
475
        for i, row in enumerate(rows):
476
            rows[i] = map(remove_col_rename, map(as_Value, row))
470 477
        
471
        self.values = values
478
        self.rows = rows
472 479
    
473 480
    def to_str(self, db):
474
        return 'VALUES ('+(', '.join((v.to_str(db) for v in self.values)))+')'
481
        def row_str(row):
482
            return '('+(', '.join((v.to_str(db) for v in row)))+')'
483
        return 'VALUES '+(', '.join(map(row_str, self.rows)))
475 484

  
476 485
##### Database structure
477 486

  

Also available in: Unified diff