summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-03-18 19:05:20 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-03-18 19:28:49 -0400
commitee9bd719b7fc5f9ad34df8815ccca56d5a7a65cc (patch)
treeb92bb404838f08e5519605227af07e2db21f0b2c /test/dialect/postgresql/test_reflection.py
parent8811ea705d22b4ee6c343683a70ad3b5fb6f3e34 (diff)
downloadsqlalchemy-ee9bd719b7fc5f9ad34df8815ccca56d5a7a65cc.tar.gz
Don't include PG INCLUDE columns as regular index columns
Fixed issue where a "covering" index, e.g. those which have an INCLUDE clause, would be reflected including all the columns in INCLUDE clause as regular columns. A warning is now emitted if these additional columns are detected indicating that they are currently ignored. Note that full support for "covering" indexes is part of :ticket:`4458`. Pull request courtesy Marat Sharafutdinov. Fixes: #5205 Closes: #5206 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5206 Pull-request-sha: 512a3817bb21991142add2d192fa7ce9b285369d Change-Id: I3196a2bf77dc5a6abd85b2fbf0ebff1b30d4fb00
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index 374bda565..8e26d5a83 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -1110,6 +1110,38 @@ class ReflectionTest(fixtures.TestBase):
"gin",
)
+ @testing.skip_if("postgresql < 11.0", "indnkeyatts not supported")
+ @testing.provide_metadata
+ def test_index_reflection_with_include(self):
+ """reflect indexes with include set"""
+
+ metadata = self.metadata
+
+ Table(
+ "t",
+ metadata,
+ Column("id", Integer, primary_key=True),
+ Column("x", ARRAY(Integer)),
+ Column("name", String(20)),
+ )
+ metadata.create_all()
+ with testing.db.connect() as conn:
+ conn.execute("CREATE INDEX idx1 ON t (x) INCLUDE (name)")
+
+ # prior to #5205, this would return:
+ # [{'column_names': ['x', 'name'],
+ # 'name': 'idx1', 'unique': False}]
+
+ with testing.expect_warnings(
+ "INCLUDE columns for "
+ "covering index idx1 ignored during reflection"
+ ):
+ ind = testing.db.dialect.get_indexes(conn, "t", None)
+ eq_(
+ ind,
+ [{"unique": False, "column_names": ["x"], "name": "idx1"}],
+ )
+
@testing.provide_metadata
def test_foreign_key_option_inspection(self):
metadata = self.metadata