2017-10-25 11:33:31 |
Belmiro Moreira |
description |
Description
===========
Archive deleted instances first moves deleted rows to the shadow
tables and then deletes the rows from the original tables.
However, because it does 2 different selects (to get the rows to insert
and to delete) we can have the case that a row is not inserted in the
shadow table but removed from the original.
This can happen when there are new deleted rows between the insert and
delete.
Shouldn't we deleted explicitly only the IDs that were inserted?
See:
insert = shadow_table.insert(inline=True).\
from_select(columns,
sql.select([table],
deleted_column != deleted_column.default.arg).
order_by(column).limit(max_rows))
query_delete = sql.select([column],
deleted_column != deleted_column.default.arg).\
order_by(column).limit(max_rows)
delete_statement = DeleteFromSelect(table, query_delete, column)
(...)
conn.execute(insert)
result_delete = conn.execute(delete_statement) |
Description
===========
Archive deleted instances first moves deleted rows to the shadow
tables and then deletes the rows from the original tables.
However, because it does 2 different selects (to get the rows to insert
and to delete) we can have the case that a row is not inserted in the
shadow table but removed from the original.
This can happen when there are new deleted rows between the insert and
delete.
Shouldn't we delete explicitly only the IDs that were inserted?
See:
insert = shadow_table.insert(inline=True).\
from_select(columns,
sql.select([table],
deleted_column != deleted_column.default.arg).
order_by(column).limit(max_rows))
query_delete = sql.select([column],
deleted_column != deleted_column.default.arg).\
order_by(column).limit(max_rows)
delete_statement = DeleteFromSelect(table, query_delete, column)
(...)
conn.execute(insert)
result_delete = conn.execute(delete_statement) |
|