Project

General

Profile

« Previous | Next » 

Revision 5523

sql.select() calls: Removed order_by=None everywhere that a stable row order is required (i.e. consistent between selects, or consistent between table transformations). This causes several tests to return different inserted row counts, because the input table is now being accessed in pkey order instead of in table order. This fixes a bug where tables with more rows than ~100 would return different results for repeated calls of the same non-ordered select.

View differences:

inputs/VegBank/taxonobservation_/test.xml.ref
150 150
        </path>
151 151
    </_simplifyPath>
152 152
</VegBIEN>
153
Inserted 34 new rows into database
153
Inserted 21 new rows into database
inputs/VegBank/taxonimportance/test.xml.ref
17 17
        </path>
18 18
    </_simplifyPath>
19 19
</VegBIEN>
20
Inserted 5 new rows into database
20
Inserted 4 new rows into database
lib/sql.py
1018 1018
    '''
1019 1019
    items = mk_flatten_mapping(db, into, cols, as_items=True, **kw_args)
1020 1020
    cols = [sql_gen.NamedCol(new.name, old) for old, new in items]
1021
    run_query_into(db, mk_select(db, joins, cols, order_by=None, limit=limit,
1022
        start=start), into=into, add_pkey_=True)
1021
    run_query_into(db, mk_select(db, joins, cols, limit=limit, start=start),
1022
        into=into, add_pkey_=True)
1023 1023
        # don't cache because the temp table will usually be truncated after use
1024 1024
    return dict(items)
1025 1025

  
lib/db_xml.py
233 233
        try: sql.add_row_num(db, in_table, 'row_num')
234 234
        except sql.DatabaseErrors: pass # already has pkey
235 235
        cur = sql.insert_select(db, in_table, None, sql.mk_select(db,
236
            full_in_table, limit=this_limit, start=start, order_by=None))
236
            full_in_table, limit=this_limit, start=start))
237 237
        
238 238
        this_ct = cur.rowcount
239 239
        total += this_ct
lib/sql_io.py
430 430
    elif is_function: full_in_table = in_table
431 431
    else:
432 432
        full_in_table = sql_gen.suffixed_table(in_table, '_full')
433
        sql.run_query_into(db, sql.mk_select(db, in_table, None, order_by=None),
434
            into=full_in_table, add_pkey_=True)
433
        sql.run_query_into(db, sql.mk_select(db, in_table), into=full_in_table,
434
            add_pkey_=True)
435 435
    
436 436
    pkeys_table_exists_ref = [False]
437 437
    def insert_into_pkeys(query, **kw_args):
......
442 442
            sql.run_query_into(db, query, into=into, add_pkey_=True, **kw_args)
443 443
            pkeys_table_exists_ref[0] = True
444 444
    
445
    def mk_main_select(joins, cols):
446
        return sql.mk_select(db, joins, cols, order_by=None)
445
    def mk_main_select(joins, cols): return sql.mk_select(db, joins, cols)
447 446
    
448 447
    if is_literals: insert_in_table = None
449 448
    else:
......
573 572
        
574 573
        sql.define_func(db, sql_gen.FunctionDef(wrapper, sql_gen.SetOf(into),
575 574
            sql_gen.RowExcIgnore(sql_gen.RowType(in_table),
576
                sql.mk_select(db, input_joins, order_by=None),
577
                mk_return(func_call), exc_handler=exc_handler)
575
                sql.mk_select(db, input_joins), mk_return(func_call),
576
                exc_handler=exc_handler)
578 577
            ))
579 578
        wrapper_table = sql_gen.FunctionCall(wrapper)
580 579
    
bin/map
343 343
            if by_col: limit = 0 # only fetch column names
344 344
            else: limit = n
345 345
            cur = sql.select(in_db, table, limit=limit, start=start,
346
                order_by=None, cacheable=False)
346
                cacheable=False)
347 347
            col_names = list(sql.col_names(cur))
348 348
            
349 349
            if by_col:

Also available in: Unified diff