From 08994cb97c501a3cf984fd827eba9aa9614b9dd3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 9 Jan 2019 11:42:02 -0500 Subject: Skip expression-based index reflection for SQLite Reflection of an index based on SQL expressions are now skipped with a warning, in the same way as that of the Postgresql dialect, where we currently do not support reflecting indexes that have SQL expressions within them. Previously, an index with columns of None were produced which would break tools like Alembic. Fixes: #4431 Change-Id: I1363ade912d206b42669331e2be2bb6f444b65a2 --- lib/sqlalchemy/dialects/sqlite/base.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/dialects/sqlite') diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 1eea2b6c6..424f91fa6 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -1941,17 +1941,24 @@ class SQLiteDialect(default.DefaultDialect): "sqlite_autoindex" ): continue - indexes.append(dict(name=row[1], column_names=[], unique=row[2])) # loop thru unique indexes to get the column names. - for idx in indexes: + for idx in list(indexes): pragma_index = self._get_table_pragma( connection, "index_info", idx["name"] ) for row in pragma_index: - idx["column_names"].append(row[2]) + if row[2] is None: + util.warn( + "Skipped unsupported reflection of " + "expression-based index %s" % idx["name"] + ) + indexes.remove(idx) + break + else: + idx["column_names"].append(row[2]) return indexes @reflection.cache -- cgit v1.2.1