Revision 5895
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/sql_io.py | ||
---|---|---|
488 | 488 |
if not is_function: |
489 | 489 |
cond = sql_gen.map_expr(db, cond, out_table_cols) |
490 | 490 |
|
491 |
not_cond = sql_gen.NotCond(sql_gen.CustomCode(cond)) |
|
492 | 491 |
log_debug('Ignoring rows that do not satisfy '+strings.as_tt(cond)) |
493 | 492 |
cur = None |
494 | 493 |
if cond == sql_gen.false_expr: |
495 | 494 |
assert failed |
496 | 495 |
remove_all_rows() |
497 | 496 |
elif cond == sql_gen.true_expr: assert passed |
498 |
else: cur = sql.delete(db, insert_in_table, not_cond) |
|
497 |
else: |
|
498 |
while True: |
|
499 |
not_cond = sql_gen.NotCond(sql_gen.CustomCode(cond)) |
|
500 |
try: |
|
501 |
cur = sql.delete(db, insert_in_table, not_cond) |
|
502 |
break |
|
503 |
except sql.DoesNotExistException, e: |
|
504 |
if e.type != 'column': raise |
|
505 |
|
|
506 |
last_cond = cond |
|
507 |
cond = sql_gen.map_expr(db, cond, {e.name: None}) |
|
508 |
if cond == last_cond: raise # not fixable |
|
499 | 509 |
|
500 | 510 |
# If any rows failed cond |
501 | 511 |
if failed or cur != None and cur.rowcount > 0: |
Also available in: Unified diff
sql_io.py: put_table(): ensure_cond(): When deleting rows rows that do not satisfy the condition, handle sql.DoesNotExistExceptions caused by columns in the condition that were not replaced with NULL. These occur when out_table is a function, and the columns of the table the condition relates to therefore can't be found using out_table.