summaryrefslogtreecommitdiff
path: root/test/dialect/mssql/test_compiler.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2020-12-08 15:23:02 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-09 09:35:52 -0500
commitfdf06c9dcf241d863d252532b801a1281f2626de (patch)
tree4cd905b10428f433a9b215cd52897a527638c0b7 /test/dialect/mssql/test_compiler.py
parentc5831b1abd98c46ef7eab7ee82ead18756aea112 (diff)
downloadsqlalchemy-fdf06c9dcf241d863d252532b801a1281f2626de.tar.gz
Fixed compile for mssql dialect
Fixed string compilation when both mssql_include and mssql_where are used Fixes: #5751 Closes: #5752 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5752 Pull-request-sha: aa57ad5d93cd69bf7728d864569c31c7e59b54fb Change-Id: I1201170affd9911c252df5c9b841e538bb577085
Diffstat (limited to 'test/dialect/mssql/test_compiler.py')
-rw-r--r--test/dialect/mssql/test_compiler.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py
index 568d346f5..8119612e1 100644
--- a/test/dialect/mssql/test_compiler.py
+++ b/test/dialect/mssql/test_compiler.py
@@ -20,6 +20,7 @@ from sqlalchemy import sql
from sqlalchemy import String
from sqlalchemy import Table
from sqlalchemy import testing
+from sqlalchemy import text
from sqlalchemy import union
from sqlalchemy import UniqueConstraint
from sqlalchemy import update
@@ -1281,6 +1282,31 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
schema.CreateIndex(idx), "CREATE INDEX foo ON test (x) INCLUDE (y)"
)
+ def test_index_include_where(self):
+ metadata = MetaData()
+ tbl = Table(
+ "test",
+ metadata,
+ Column("x", Integer),
+ Column("y", Integer),
+ Column("z", Integer),
+ )
+ idx = Index(
+ "foo", tbl.c.x, mssql_include=[tbl.c.y], mssql_where=tbl.c.y > 1
+ )
+ self.assert_compile(
+ schema.CreateIndex(idx),
+ "CREATE INDEX foo ON test (x) INCLUDE (y) WHERE y > 1",
+ )
+
+ idx = Index(
+ "foo", tbl.c.x, mssql_include=[tbl.c.y], mssql_where=text("y > 1")
+ )
+ self.assert_compile(
+ schema.CreateIndex(idx),
+ "CREATE INDEX foo ON test (x) INCLUDE (y) WHERE y > 1",
+ )
+
def test_try_cast(self):
metadata = MetaData()
t1 = Table("t1", metadata, Column("id", Integer, primary_key=True))