Skip to content

Commit

Permalink
Merge pull request #66 from stackhpc/upstream/wallaby-2024-01-01
Browse files Browse the repository at this point in the history
Synchronise wallaby with upstream
  • Loading branch information
markgoddard authored Jan 2, 2024
2 parents a19a836 + 860d79f commit 428772e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions nova/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4133,6 +4133,12 @@ def _get_fk_stmts(metadata, conn, table, column, records):
fk_column = fk_table.c.id

for fk in fk_table.foreign_keys:
if table != fk.column.table:
# if the foreign key doesn't actually point to the table we're
# archiving entries from then it's not relevant; trying to
# resolve this would result in a cartesian product
continue

# We need to find the records in the referring (child) table that
# correspond to the records in our (parent) table so we can archive
# them.
Expand Down Expand Up @@ -4179,6 +4185,7 @@ def _get_fk_stmts(metadata, conn, table, column, records):
# deque.
fk_delete = fk_table.delete().where(fk_column.in_(fk_records))
deletes.appendleft(fk_delete)

# Repeat for any possible nested child tables.
i, d = _get_fk_stmts(metadata, conn, fk_table, fk_column, fk_records)
inserts.extendleft(i)
Expand Down
12 changes: 8 additions & 4 deletions nova/objects/cell_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,15 @@ def _get_by_project_id_from_db(context, project_id):
# SELECT DISTINCT cell_id FROM instance_mappings \
# WHERE project_id = $project_id;
cell_ids = context.session.query(
api_models.InstanceMapping.cell_id).filter_by(
project_id=project_id).distinct().subquery()
api_models.InstanceMapping.cell_id
).filter_by(
project_id=project_id
).distinct()
# SELECT cell_mappings WHERE cell_id IN ($cell_ids);
return context.session.query(api_models.CellMapping).filter(
api_models.CellMapping.id.in_(cell_ids)).all()
return context.session.query(
api_models.CellMapping).filter(
api_models.CellMapping.id.in_(cell_ids)
).all()

@classmethod
def get_by_project_id(cls, context, project_id):
Expand Down

0 comments on commit 428772e

Please sign in to comment.