Merge "db: Resolve additional SAWarning warnings"
This commit is contained in:
commit
c625698823
@ -4274,6 +4274,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.
|
||||
@ -4325,6 +4331,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)
|
||||
|
@ -279,11 +279,15 @@ class CellMappingList(base.ObjectListBase, base.NovaObject):
|
||||
# SELECT DISTINCT cell_id FROM instance_mappings \
|
||||
# WHERE project_id = $project_id;
|
||||
cell_ids = context.session.query(
|
||||
api_db_models.InstanceMapping.cell_id).filter_by(
|
||||
project_id=project_id).distinct().subquery()
|
||||
api_db_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_db_models.CellMapping).filter(
|
||||
api_db_models.CellMapping.id.in_(cell_ids)).all()
|
||||
return context.session.query(
|
||||
api_db_models.CellMapping).filter(
|
||||
api_db_models.CellMapping.id.in_(cell_ids)
|
||||
).all()
|
||||
|
||||
@classmethod
|
||||
def get_by_project_id(cls, context, project_id):
|
||||
|
16
nova/tests/fixtures/nova.py
vendored
16
nova/tests/fixtures/nova.py
vendored
@ -850,12 +850,6 @@ class WarningsFixture(fixtures.Fixture):
|
||||
category=UserWarning,
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'error',
|
||||
message='Evaluating non-mapped column expression',
|
||||
category=sqla_exc.SAWarning,
|
||||
)
|
||||
|
||||
# Enable deprecation warnings for nova itself to capture upcoming
|
||||
# SQLAlchemy changes
|
||||
|
||||
@ -870,6 +864,16 @@ class WarningsFixture(fixtures.Fixture):
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
)
|
||||
|
||||
# Enable general SQLAlchemy warnings also to ensure we're not doing
|
||||
# silly stuff. It's possible that we'll need to filter things out here
|
||||
# with future SQLAlchemy versions, but that's a good thing
|
||||
|
||||
warnings.filterwarnings(
|
||||
'error',
|
||||
module='nova',
|
||||
category=sqla_exc.SAWarning,
|
||||
)
|
||||
|
||||
self.addCleanup(self._reset_warning_filters)
|
||||
|
||||
def _reset_warning_filters(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user