From bd1d6012dcbe5fbc6d1097a79d85b972b0d4fd8a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 10 May 2018 11:39:06 -0400 Subject: SQL Server is not native boolean; add new flag for CHECK constraint Fixed a 1.2 regression caused by :ticket:`4061` where the SQL Server "BIT" type would be considered to be "native boolean". The goal here was to avoid creating a CHECK constraint on the column, however the bigger issue is that the BIT value does not behave like a true/false constant and cannot be interpreted as a standalone expression, e.g. "WHERE ". The SQL Server dialect now goes back to being non-native boolean, but with an extra flag that still avoids creating the CHECK constraint. Change-Id: I4765d2a2a00b0d14f50282603cc4d48d4739dac1 Fixes: #4250 --- lib/sqlalchemy/sql/sqltypes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 573fda98f..a2ae9de50 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1643,7 +1643,8 @@ class Boolean(Emulated, TypeEngine, SchemaType): def _should_create_constraint(self, compiler, **kw): if not self._is_impl_for_variant(compiler.dialect, kw): return False - return not compiler.dialect.supports_native_boolean + return not compiler.dialect.supports_native_boolean and \ + compiler.dialect.non_native_boolean_check_constraint @util.dependencies("sqlalchemy.sql.schema") def _set_table(self, schema, column, table): -- cgit v1.2.1