From: mike bayer Date: Sat, 12 Sep 2020 19:46:50 +0000 (+0000) Subject: Merge "Improve handling of covering indexes" X-Git-Tag: rel_1_4_0b1~102 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=645be4aa24a06241dfeb635aee8ca7a09574d800;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Merge "Improve handling of covering indexes" --- 645be4aa24a06241dfeb635aee8ca7a09574d800 diff --cc lib/sqlalchemy/dialects/mssql/base.py index b398610b23,ae852f2643..519d74d89e --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@@ -2873,16 -2864,12 +2873,18 @@@ class MSDialect(default.DefaultDialect) "name": row["name"], "unique": row["is_unique"] == 1, "column_names": [], + "include_columns": [], } + + if row["filter_definition"] is not None: + indexes[row["index_id"]].setdefault("dialect_options", {})[ + "mssql_where" + ] = row["filter_definition"] + rp = connection.execution_options(future_result=True).execute( sql.text( - "select ind_col.index_id, ind_col.object_id, col.name " + "select ind_col.index_id, ind_col.object_id, col.name, " + "ind_col.is_included_column " "from sys.columns as col " "join sys.tables as tab on tab.object_id=col.object_id " "join sys.index_columns as ind_col on " diff --cc lib/sqlalchemy/dialects/postgresql/base.py index 93ee7ca294,ffd926c460..3ef87620fd --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@@ -2253,12 -2279,7 +2277,11 @@@ class PGDDLCompiler(compiler.DDLCompile text += " TABLESPACE %s" % preparer.quote(tablespace_name) whereclause = index.dialect_options["postgresql"]["where"] - if whereclause is not None: + whereclause = coercions.expect( + roles.DDLExpressionRole, whereclause + ) + where_compiled = self.sql_compiler.process( whereclause, include_table=False, literal_binds=True )