Revision 3092
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
669 | 669 |
|
670 | 670 |
lang = 'sql' |
671 | 671 |
if ignore: |
672 |
assert cols != None |
|
673 | 672 |
# Always return something to set the correct rowcount |
674 | 673 |
if returning == None: returning = sql_gen.NamedCol('NULL', None) |
675 | 674 |
|
676 | 675 |
embeddable = True # must use function |
677 | 676 |
lang = 'plpgsql' |
678 |
row = [sql_gen.Col(c.name, 'row') for c in cols] |
|
679 | 677 |
|
678 |
if cols == None: |
|
679 |
row = [sql_gen.Col(sql_gen.all_cols, 'row')] |
|
680 |
row_vars = [sql_gen.Table('row')] |
|
681 |
else: |
|
682 |
row_vars = row = [sql_gen.Col(c.name, 'row') for c in cols] |
|
683 |
|
|
680 | 684 |
query = '''\ |
681 | 685 |
DECLARE |
682 | 686 |
row '''+table.to_str(db)+'''%ROWTYPE; |
... | ... | |
689 | 693 |
(http://www.postgresql.org/docs/8.3/static/plpgsql-control-structures.html\ |
690 | 694 |
#PLPGSQL-ERROR-TRAPPING) |
691 | 695 |
*/ |
692 |
FOR '''+(', '.join((c.to_str(db) for c in row)))+''' IN
|
|
696 |
FOR '''+(', '.join((v.to_str(db) for v in row_vars)))+''' IN
|
|
693 | 697 |
'''+select_query+''' |
694 | 698 |
LOOP |
695 | 699 |
BEGIN |
Also available in: Unified diff
sql.py: mk_insert_select(): ignore mode: Support inserting all columns when cols == None