summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-08-30 12:23:31 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-08-30 12:27:03 -0400
commit3e855cd277aac8a71be31082cbc11927005f5b37 (patch)
treefc434c89e32c5d7a7b89e7b381e26e2404d80d1a
parent812c08efb41ff0a8bdafb876fe49079da5074916 (diff)
downloadsqlalchemy-3e855cd277aac8a71be31082cbc11927005f5b37.tar.gz
Ignore SQL Server "heap" indexes
Added a rule to SQL Server index reflection to ignore the so-called "heap" index that is implicitly present on a table that does not specify a clustered index. Tests are part of standard suite already (CI has been disabled) Change-Id: I593b95551c40ee5d95d54203611112cbff10856f Fixes: #4059
-rw-r--r--doc/build/changelog/unreleased_12/4059.rst8
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/doc/build/changelog/unreleased_12/4059.rst b/doc/build/changelog/unreleased_12/4059.rst
new file mode 100644
index 000000000..bedbdd17d
--- /dev/null
+++ b/doc/build/changelog/unreleased_12/4059.rst
@@ -0,0 +1,8 @@
+.. change::
+ :tags: bug, mssql
+ :tickets: 4059
+
+ Added a rule to SQL Server index reflection to ignore the so-called
+ "heap" index that is implicitly present on a table that does not
+ specify a clustered index.
+
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 05381d671..d526c685c 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -1939,7 +1939,7 @@ class MSDialect(default.DefaultDialect):
"join sys.schemas as sch on sch.schema_id=tab.schema_id "
"where tab.name = :tabname "
"and sch.name=:schname "
- "and ind.is_primary_key=0",
+ "and ind.is_primary_key=0 and ind.type != 0",
bindparams=[
sql.bindparam('tabname', tablename,
sqltypes.String(convert_unicode=True)),