Skip to content

Commit cd9b792

Browse files
committed
db: Replace use of 'autoload' parameter
Resolve the following RemovedIn20Warning warnings: The autoload parameter is deprecated and will be removed in version 2.0. Please use the autoload_with parameter, passing an engine or connection. Change-Id: I10e9bbf14706aece2a59ebb5861004c5b852a592 Signed-off-by: Stephen Finucane <[email protected]>
1 parent cd3e5a2 commit cd9b792

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

nova/db/main/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4162,7 +4162,7 @@ def _get_fk_stmts(metadata, conn, table, column, records):
41624162
fk_shadow_tablename = _SHADOW_TABLE_PREFIX + fk_table.name
41634163
try:
41644164
fk_shadow_table = schema.Table(
4165-
fk_shadow_tablename, metadata, autoload=True)
4165+
fk_shadow_tablename, metadata, autoload_with=conn)
41664166
except sqla_exc.NoSuchTableError:
41674167
# No corresponding shadow table; skip it.
41684168
continue
@@ -4257,7 +4257,8 @@ def _archive_deleted_rows_for_table(metadata, tablename, max_rows, before,
42574257
rows_archived = 0
42584258
deleted_instance_uuids = []
42594259
try:
4260-
shadow_table = schema.Table(shadow_tablename, metadata, autoload=True)
4260+
shadow_table = schema.Table(
4261+
shadow_tablename, metadata, autoload_with=conn)
42614262
except sqla_exc.NoSuchTableError:
42624263
# No corresponding shadow table; skip it.
42634264
return rows_archived, deleted_instance_uuids, {}

nova/db/main/legacy_migrations/versions/402_train.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _create_shadow_tables(migrate_engine):
6363
):
6464
continue
6565

66-
table = sa.Table(table_name, meta, autoload=True)
66+
table = sa.Table(table_name, meta, autoload_with=migrate_engine)
6767

6868
columns = []
6969
for column in table.columns:
@@ -169,13 +169,15 @@ def _create_shadow_tables(migrate_engine):
169169
# 252_add_instance_extra_table; we don't create indexes for shadow tables
170170
# in general and these should be removed
171171

172-
table = sa.Table('shadow_instance_extra', meta, autoload=True)
172+
table = sa.Table(
173+
'shadow_instance_extra', meta, autoload_with=migrate_engine,
174+
)
173175
idx = sa.Index('shadow_instance_extra_idx', table.c.instance_uuid)
174176
idx.create(migrate_engine)
175177

176178
# 373_migration_uuid; we should't create indexes for shadow tables
177179

178-
table = sa.Table('shadow_migrations', meta, autoload=True)
180+
table = sa.Table('shadow_migrations', meta, autoload_with=migrate_engine)
179181
idx = sa.Index('shadow_migrations_uuid', table.c.uuid, unique=True)
180182
idx.create(migrate_engine)
181183

nova/tests/fixtures/nova.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,6 @@ def setUp(self):
841841
message=r'The Engine.execute\(\) method is considered legacy',
842842
category=sqla_exc.SADeprecationWarning)
843843

844-
warnings.filterwarnings(
845-
'ignore',
846-
module='nova',
847-
message=r'The autoload parameter is deprecated .*',
848-
category=sqla_exc.SADeprecationWarning)
849-
850844
warnings.filterwarnings(
851845
'ignore',
852846
module='nova',

nova/tests/unit/db/main/test_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5714,8 +5714,10 @@ def test_shadow_tables(self):
57145714

57155715
shadow_table_name = f'shadow_{table_name}'
57165716

5717-
table = sa.Table(table_name, metadata, autoload=True)
5718-
shadow_table = sa.Table(shadow_table_name, metadata, autoload=True)
5717+
table = sa.Table(table_name, metadata, autoload_with=self.engine)
5718+
shadow_table = sa.Table(
5719+
shadow_table_name, metadata, autoload_with=self.engine,
5720+
)
57195721

57205722
columns = {c.name: c for c in table.columns}
57215723
shadow_columns = {c.name: c for c in shadow_table.columns}

0 commit comments

Comments
 (0)