From 1a08d1aade046e9516d0527ffd2ac8bb43906171 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Tue, 1 Sep 2020 14:36:40 -0600 Subject: Improve handling of covering indexes Improved support for covering indexes (with INCLUDE columns). Added the ability for postgresql to render CREATE INDEX statements with an INCLUDE clause from Core. Index reflection also report INCLUDE columns separately for both mssql and postgresql (11+). Fixes: #4458 Change-Id: If0b82103fbc898cdaeaf6a6d2d421c732744acd6 --- test/dialect/postgresql/test_compiler.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 556601fc6..c20498b2d 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -1721,6 +1721,34 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "(INCREMENT BY 7 START WITH 4))", ) + def test_index_extra_include_1(self): + metadata = MetaData() + tbl = Table( + "test", + metadata, + Column("x", Integer), + Column("y", Integer), + Column("z", Integer), + ) + idx = Index("foo", tbl.c.x, postgresql_include=["y"]) + self.assert_compile( + schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)" + ) + + def test_index_extra_include_2(self): + metadata = MetaData() + tbl = Table( + "test", + metadata, + Column("x", Integer), + Column("y", Integer), + Column("z", Integer), + ) + idx = Index("foo", tbl.c.x, postgresql_include=[tbl.c.y]) + self.assert_compile( + schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)" + ) + class InsertOnConflictTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = postgresql.dialect() -- cgit v1.2.1