Project

General

Profile

« Previous | Next » 

Revision 3018

sql.py: mk_insert_select(): INSERT IGNORE: Use RETURN QUERY on the insert query instead of RETURN NEXT on a local var to forward the RETURNING value

View differences:

lib/sql.py
664 664
        
665 665
        query = '''\
666 666
DECLARE
667
    returning_ '''+return_type+''';
668 667
    row '''+table.to_str(db)+'''%ROWTYPE;
669 668
    cur CURSOR FOR
670 669
'''+select_query+'''
......
686 685
'''+(', '.join((c.to_str(db) for c in row)))+''';
687 686
                EXIT outer WHEN NOT FOUND;
688 687
                
688
                RETURN QUERY
689 689
'''+mk_insert(sql_gen.Values(row).to_str(db))+'''
690
INTO STRICT returning_
691 690
;
692
                IF FOUND THEN
693
                    RETURN NEXT returning_;
694
                END IF;
695 691
            END LOOP;
696 692
        EXCEPTION
697 693
            WHEN unique_violation THEN NULL; -- outer loop continues to next row

Also available in: Unified diff