Project

General

Profile

« Previous | Next » 

Revision 2134

sql.py: put_table(): Added support for putting just a window subset of the rows in the table. Removed "SELECT statement missing a WHERE, LIMIT, or OFFSET clause" warnings.

View differences:

lib/sql.py
437 437
        run_query(db, function_query, cacheable=True)
438 438
        
439 439
        # Return query that uses function
440
        return mk_select(db, function+'() AS f ('+returning+')', order_by=None,
441
            table_is_esc=True) # function alias is required in AS clause
440
        return mk_select(db, function+'() AS f ('+returning+')', start=0,
441
            order_by=None, table_is_esc=True)# AS clause requires function alias
442 442
    
443 443
    return (query, params)
444 444

  
......
636 636
        if not create: raise
637 637
        return put(db, table, row, pkey, row_ct_ref) # insert new row
638 638

  
639
def put_table(db, out_table, in_tables, mapping, row_ct_ref=None,
640
    table_is_esc=False):
639
def put_table(db, out_table, in_tables, mapping, limit=None, start=0,
640
    row_ct_ref=None, table_is_esc=False):
641 641
    '''Recovers from errors.
642 642
    Only works under PostgreSQL (uses INSERT RETURNING).
643 643
    @param in_tables The main input table to select from, followed by a list of
......
657 657
    joins = [in_tables0] + [(t, {in_pkey: join_using}) for t in in_tables]
658 658
    
659 659
    def mk_select_(cols):
660
        return mk_select(db, joins, cols, table_is_esc=table_is_esc)
660
        return mk_select(db, joins, cols, limit=limit, start=start,
661
            table_is_esc=table_is_esc)
661 662
    
662 663
    out_pkeys = out_table_clean+'_out_pkeys'
663 664
    def insert_():
......
676 677
        # Join together out_pkeys and in_pkeys
677 678
        run_query_into(db, *mk_select(db,
678 679
            [in_pkeys, (out_pkeys, {row_num_col: join_using})],
679
            [in_pkey, out_pkey]), into=pkeys)
680
            [in_pkey, out_pkey], start=0), into=pkeys)
680 681
    
681 682
    try:
682 683
        # Insert and capture output pkeys
lib/db_xml.py
171 171
    
172 172
    # Insert node
173 173
    pkeys_loc = sql.put_table(db, esc_name(out_table), in_tables, row,
174
        row_ct_ref, table_is_esc=True)
174
        row_ct_ref=row_ct_ref, table_is_esc=True)
175 175
    
176 176
    if commit: db.db.commit()
177 177
    return pkeys_loc

Also available in: Unified diff