diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-23 18:38:48 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-07-24 09:30:57 -0400 |
commit | 33616a85c7c35ec1b1756a43e44a621b744e75fa (patch) | |
tree | f3309a93aed55d77e29313d6404b9bbd75c52774 /test/sql/test_constraints.py | |
parent | 8f5b65f4316e21d19b00266cdd9eded3d4ec51b2 (diff) | |
download | sqlalchemy-33616a85c7c35ec1b1756a43e44a621b744e75fa.tar.gz |
Ensure all Index arguments are counted when matching expr/columns
Fixed issue where :class:`.Index` object which contained a mixture of
functional expressions which were not resolvable to a particular column,
in combination with string-based column names, would fail to initialize
its internal state correctly leading to failures during DDL compilation.
Fixes: #4778
Change-Id: I0fa9c627a1fde92ba8b9ed10af167c156012bd5d
Diffstat (limited to 'test/sql/test_constraints.py')
-rw-r--r-- | test/sql/test_constraints.py | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index d22388f44..019409ba3 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -823,20 +823,44 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): dialect=dialect, ) - def test_functional_index(self): + def test_functional_index_w_string_cols_combo(self): metadata = MetaData() - x = Table("x", metadata, Column("q", String(50))) - idx = Index("y", func.lower(x.c.q)) - - self.assert_compile( - schema.CreateIndex(idx), "CREATE INDEX y ON x (lower(q))" + x = Table( + "x", + metadata, + Column("q", String(50)), + Column("p", Integer), + Column("z", Integer), ) - self.assert_compile( - schema.CreateIndex(idx), - "CREATE INDEX y ON x (lower(q))", - dialect=testing.db.dialect, - ) + for idx, ddl in [ + ( + Index("y", func.lower(x.c.q), "p", x.c.z), + "CREATE INDEX y ON x (lower(q), p, z)", + ), + ( + Index("y", "p", func.lower(x.c.q), "z"), + "CREATE INDEX y ON x (p, lower(q), z)", + ), + ( + Index("y", "p", "z", func.lower(x.c.q)), + "CREATE INDEX y ON x (p, z, lower(q))", + ), + ( + Index("y", func.foo("foob"), x.c.p, "z"), + "CREATE INDEX y ON x (foo('foob'), p, z)", + ), + ( + Index("y", x.c.p, func.foo("foob"), "z"), + "CREATE INDEX y ON x (p, foo('foob'), z)", + ), + ( + Index("y", func.foo("foob"), "p", "z"), + "CREATE INDEX y ON x (foo('foob'), p, z)", + ), + ]: + x.append_constraint(idx) + self.assert_compile(schema.CreateIndex(idx), ddl) def test_index_against_text_separate(self): metadata = MetaData() |