Revision 3291
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_io.py | ||
---|---|---|
376 | 376 |
log_debug('Trying to insert new rows') |
377 | 377 |
|
378 | 378 |
# Prepare to insert new rows |
379 |
insert_args = dict(recover=True, cacheable=False) |
|
380 |
if has_joins: |
|
381 |
insert_args.update(dict(ignore=True)) |
|
379 |
if is_function: |
|
380 |
log_debug('Calling function on input rows') |
|
381 |
args = dict(((k.name, v) for k, v in mapping.iteritems())) |
|
382 |
func_call = sql_gen.NamedCol(out_pkey, |
|
383 |
sql_gen.FunctionCall(out_table, **args)) |
|
382 | 384 |
else: |
383 |
insert_args.update(dict(returning=out_pkey, into=insert_out_pkeys)) |
|
384 |
main_select = mk_main_select([insert_in_table], |
|
385 |
[sql_gen.with_table(c, insert_in_table) for c in mapping.values()]) |
|
385 |
insert_args = dict(recover=True, cacheable=False) |
|
386 |
if has_joins: |
|
387 |
insert_args.update(dict(ignore=True)) |
|
388 |
else: |
|
389 |
insert_args.update(dict(returning=out_pkey, |
|
390 |
into=insert_out_pkeys)) |
|
391 |
main_select = mk_main_select([insert_in_table], [sql_gen.with_table( |
|
392 |
c, insert_in_table) for c in mapping.values()]) |
|
386 | 393 |
|
387 | 394 |
def main_insert(): |
388 | 395 |
if is_function: |
389 |
log_debug('Calling function on input rows') |
|
390 |
args = dict(((k.name, v) for k, v in mapping.iteritems())) |
|
391 |
func_call = sql_gen.NamedCol(out_pkey, |
|
392 |
sql_gen.FunctionCall(out_table, **args)) |
|
393 | 396 |
insert_into_pkeys(input_joins, [in_pkey_col, func_call], |
394 | 397 |
recover=True) |
395 | 398 |
return None |
Also available in: Unified diff
sql_io.py: put_table(): main_insert(): Moved code that is not part of the main query outside the function, so it wouldn't be subject to the exception handling. Preparing to insert new rows: Only do the preparation code for insert_select() if the out_table is not a function.