Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken queries on rerun #867

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions leapp/utils/audit/contextclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def _dup_audit(db, message, data_source, newcontext, oldcontext):
return lookup


def _dup_metadata(db, newcontext, oldcontext):
for row in _fetch_table_for_context(db, 'metadata', oldcontext):
# id context kind name metadata
row_id, kind, name, metadata = _row_tuple(row, 'id', 'kind', 'name', 'metadata')
def _dup_entity(db, newcontext, oldcontext):
for row in _fetch_table_for_context(db, 'entity', oldcontext):
# id context kind name metadata_hash
row_id, kind, name, metadata_hash = _row_tuple(row, 'id', 'kind', 'name', 'metadata_hash')

db.execute(
'INSERT INTO metadata (context, kind, name, metadata) VALUES(?, ?, ?, ?)',
(newcontext, kind, name, metadata))
'INSERT INTO entity (context, kind, name, metadata_hash) VALUES(?, ?, ?, ?)',
(newcontext, kind, name, metadata_hash))


def _dup_dialog(db, data_source, newcontext, oldcontext):
Expand All @@ -102,5 +102,5 @@ def clone_context(oldcontext, newcontext, use_db=None):
message = _dup_message(db=db, data_source=data_source, newcontext=newcontext, oldcontext=oldcontext)
# Last clone message entries and use the lookup table generated by the data_source and message duplications
_dup_audit(db=db, data_source=data_source, message=message, newcontext=newcontext, oldcontext=oldcontext)
_dup_metadata(db=db, oldcontext=oldcontext, newcontext=newcontext)
_dup_entity(db=db, oldcontext=oldcontext, newcontext=newcontext)
_dup_dialog(db=db, data_source=data_source, oldcontext=oldcontext, newcontext=newcontext)