[Sqlalchemy-tickets] Issue #4147: Incorrect handling of complex indexes by Table.tometadata (zzzeek
Brought to you by:
zzzeek
From: Paweł S. <iss...@bi...> - 2017-12-14 18:26:50
|
New issue 4147: Incorrect handling of complex indexes by Table.tometadata https://bitbucket.org/zzzeek/sqlalchemy/issues/4147/incorrect-handling-of-complex-indexes-by Paweł Stiasny: Current implementation Table.tometada doesn't correctly support functional and text indexes. Consider the following test: ```diff diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 45eb594..25ac689 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -1042,18 +1042,21 @@ class ToMetaDataTest(fixtures.TestBase, ComparesTables): def test_indexes(self): meta = MetaData() table = Table('mytable', meta, 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) def _get_key(i): return [i.name, i.unique] + \ sorted(i.kwargs.items()) + \ list(i.columns.keys()) ``` * The `text` expression index is ignored * `func` is improperly classified as the default index of a column and ignored * In `multi-func` the second component is incorrect (should be a Function, is a Column) |