Project

General

Profile

« Previous | Next » 

Revision 2423

db_xml.py: put_table(): Count # rows and update in_row_ct_ref once all columns have been processed. Don't pass in_row_ct_ref to recursive calls because it should only be increased once.

View differences:

lib/db_xml.py
140 140
    '''
141 141
    in_table = sql_gen.as_Table(in_table)
142 142
    
143
    # Subset in_table
143 144
    if limit != None or start != 0:
144 145
        in_table = copy.copy(in_table) # don't modify input!
145 146
        sql.run_query_into(db, *sql.mk_select(db, in_table, limit=limit,
......
149 150
    def pkey(table): return sql.pkey(db, table, True)
150 151
    
151 152
    def put_table_(node, parent_ids_loc=None):
152
        return put_table(db, node, in_table, commit, in_row_ct_ref,
153
            row_ins_ct_ref, parent_ids_loc=parent_ids_loc)
153
        return put_table(db, node, in_table, commit, row_ins_ct_ref,
154
            parent_ids_loc=parent_ids_loc)
154 155
    
155 156
    out_table = name_of(node)
156 157
    row = {}
......
197 198
    # Insert children with fkeys to parent
198 199
    for child in children: put_table_(child, pkeys_loc)
199 200
    
201
    # Count # rows and update in_row_ct_ref once all columns have been processed
202
    if in_row_ct_ref != None:
203
        in_row_ct_ref[0] += sql.value(sql.run_query(db,
204
            *sql.mk_select(db, in_table, [sql_gen.CustomCode('count(*)')],
205
            order_by=None)))
206
    
200 207
    return pkeys_loc

Also available in: Unified diff