From 5ada58954afa4fa427f4f7a91c683c1210d3d6df Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Mon, 20 Dec 2021 14:37:13 -0700 Subject: Reflect included columns as dialect_options Fixed reflection of covering indexes to report ``include_columns`` as part of the ``dialect_options`` entry in the reflected index dictionary, thereby enabling round trips from reflection->create to be complete. Included columns continue to also be present under the ``include_columns`` key for backwards compatibility. Fixes: #7382 Change-Id: I4f16b65caed3a36d405481690a3a92432b5efd62 --- lib/sqlalchemy/testing/suite/test_reflection.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index ba176bcd9..9287f76de 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -1232,6 +1232,9 @@ class ComponentReflectionTestExtra(fixtures.TestBase): ] if testing.requires.index_reflects_included_columns.enabled: expected[0]["include_columns"] = [] + expected[0]["dialect_options"] = { + "%s_include" % connection.engine.name: [] + } with expect_warnings( "Skipped unsupported reflection of expression-based index t_idx" @@ -1264,10 +1267,21 @@ class ComponentReflectionTestExtra(fixtures.TestBase): "column_names": ["x"], "include_columns": ["y"], "unique": False, + "dialect_options": { + "%s_include" % connection.engine.name: ["y"] + }, } ], ) + t2 = Table("t", MetaData(), autoload_with=connection) + eq_( + list(t2.indexes)[0].dialect_options[connection.engine.name][ + "include" + ], + ["y"], + ) + def _type_round_trip(self, connection, metadata, *types): t = Table( "t", -- cgit v1.2.1