Skip to content

Commit 428772e

Browse files
authored
Merge pull request #66 from stackhpc/upstream/wallaby-2024-01-01
Synchronise wallaby with upstream
2 parents a19a836 + 860d79f commit 428772e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

nova/db/sqlalchemy/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4133,6 +4133,12 @@ def _get_fk_stmts(metadata, conn, table, column, records):
41334133
fk_column = fk_table.c.id
41344134

41354135
for fk in fk_table.foreign_keys:
4136+
if table != fk.column.table:
4137+
# if the foreign key doesn't actually point to the table we're
4138+
# archiving entries from then it's not relevant; trying to
4139+
# resolve this would result in a cartesian product
4140+
continue
4141+
41364142
# We need to find the records in the referring (child) table that
41374143
# correspond to the records in our (parent) table so we can archive
41384144
# them.
@@ -4179,6 +4185,7 @@ def _get_fk_stmts(metadata, conn, table, column, records):
41794185
# deque.
41804186
fk_delete = fk_table.delete().where(fk_column.in_(fk_records))
41814187
deletes.appendleft(fk_delete)
4188+
41824189
# Repeat for any possible nested child tables.
41834190
i, d = _get_fk_stmts(metadata, conn, fk_table, fk_column, fk_records)
41844191
inserts.extendleft(i)

nova/objects/cell_mapping.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,15 @@ def _get_by_project_id_from_db(context, project_id):
279279
# SELECT DISTINCT cell_id FROM instance_mappings \
280280
# WHERE project_id = $project_id;
281281
cell_ids = context.session.query(
282-
api_models.InstanceMapping.cell_id).filter_by(
283-
project_id=project_id).distinct().subquery()
282+
api_models.InstanceMapping.cell_id
283+
).filter_by(
284+
project_id=project_id
285+
).distinct()
284286
# SELECT cell_mappings WHERE cell_id IN ($cell_ids);
285-
return context.session.query(api_models.CellMapping).filter(
286-
api_models.CellMapping.id.in_(cell_ids)).all()
287+
return context.session.query(
288+
api_models.CellMapping).filter(
289+
api_models.CellMapping.id.in_(cell_ids)
290+
).all()
287291

288292
@classmethod
289293
def get_by_project_id(cls, context, project_id):

0 commit comments

Comments
 (0)