Revision 5993
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/sql_io.py | ||
---|---|---|
768 | 768 |
if not is_function: # is_function doesn't leave holes |
769 | 769 |
log_debug('Setting pkeys of missing rows to ' |
770 | 770 |
+strings.as_tt(strings.urepr(default))) |
771 |
|
|
772 |
full_in_pkey_col = sql_gen.Col(in_pkey, full_in_table) |
|
771 | 773 |
if sql_gen.is_table_col(default): |
772 | 774 |
default = sql_gen.with_table(default, full_in_table) |
773 | 775 |
missing_rows_joins = [full_in_table, sql_gen.Join(into, |
774 | 776 |
{in_pkey: sql_gen.join_same_not_null}, sql_gen.filter_out)] |
775 | 777 |
# must use join_same_not_null or query will take forever |
778 |
|
|
779 |
insert_args = dict(order_by=None) |
|
780 |
if not sql.table_has_pkey(db, full_in_table): # in_table has duplicates |
|
781 |
insert_args.update(dict(distinct_on=[full_in_pkey_col])) |
|
782 |
|
|
776 | 783 |
insert_into_pkeys(sql.mk_select(db, missing_rows_joins, |
777 |
[sql_gen.Col(in_pkey, full_in_table),
|
|
778 |
sql_gen.NamedCol(into_out_pkey, default)], order_by=None))
|
|
784 |
[full_in_pkey_col, sql_gen.NamedCol(into_out_pkey, default)],
|
|
785 |
**insert_args))
|
|
779 | 786 |
# otherwise, there is already an entry for every row |
780 | 787 |
|
781 | 788 |
assert (sql.table_row_count(db, into) |
Also available in: Unified diff
sql_io.py: put_table(): Setting pkeys of missing rows: Fixed bug in column-based import where when input rows match multiple output rows in one of this iteration's input tables, the into table's pkey constraint is violated because full_in_table contains multiple entries for an input pkey