diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-12-14 13:58:58 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-12-14 13:58:58 -0500 |
| commit | 31dd4824d33572b708abd331b3271a298d14966c (patch) | |
| tree | 505e0a10a5d5778c31ab3035c98a18a680d0398b /test/sql | |
| parent | 04937652f426e518781b2b762b0e0e8090857cbd (diff) | |
| download | sqlalchemy-31dd4824d33572b708abd331b3271a298d14966c.tar.gz | |
Fully copy index expressions
Fixed bug where the :meth:`.Table.tometadata` method would not properly
accommodate :class:`.Index` objects that didn't consist of simple
column expressions, such as indexes against a :func:`.text` construct,
indexes that used SQL expressions or :attr:`.func`, etc. The routine
now copies expressions fully to a new :class:`.Index` object while
substituting all table-bound :class:`.Column` objects for those
of the target table.
Also refined the means by which tometadata() checks if an Index
or UniqueConstraint is generated by a column-level flag, by propagating
an attribute "_column_flag=True" to such indexes/constraints.
Change-Id: I7ef1b8ea42f9933357ae35f241a5ba9838bac35b
Fixes: #4147
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_metadata.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 45eb59453..7d17e25f3 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1047,8 +1047,11 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables): Column('id', Integer, primary_key=True), Column('data1', Integer, index=True), Column('data2', Integer), + Index('text', text('data1 + 1')), ) - Index('multi', table.c.data1, table.c.data2), + Index('multi', table.c.data1, table.c.data2) + Index('func', func.abs(table.c.data1)) + Index('multi-func', table.c.data1, func.abs(table.c.data2)) meta2 = MetaData() table_c = table.tometadata(meta2) @@ -1056,7 +1059,7 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables): def _get_key(i): return [i.name, i.unique] + \ sorted(i.kwargs.items()) + \ - list(i.columns.keys()) + [str(col) for col in i.expressions] eq_( sorted([_get_key(i) for i in table.indexes]), |
