--- /dev/null
+.. change::
+ :tags: bug, mssql
+ :tickets: 4250
+
+ 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 <column>". The SQL Server dialect now goes back to being
+ non-native boolean, but with an extra flag that still avoids creating
+ the CHECK constraint.
ischema_names = ischema_names
- supports_native_boolean = True
+ supports_native_boolean = False
+ non_native_boolean_check_constraint = False
supports_unicode_binds = True
postfetch_lastrowid = True
supports_native_enum = False
supports_native_boolean = False
+ non_native_boolean_check_constraint = True
supports_simple_order_by_label = True
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):
(None, None)
)
+ def test_whereclause(self):
+ # testing "WHERE <column>" renders a compatible expression
+ boolean_table = self.tables.boolean_table
+
+ with config.db.connect() as conn:
+ conn.execute(
+ boolean_table.insert(),
+ [
+ {'id': 1, 'value': True, 'unconstrained_value': True},
+ {'id': 2, 'value': False, 'unconstrained_value': False}
+ ]
+ )
+
+ eq_(
+ conn.scalar(
+ select([boolean_table.c.id]).where(boolean_table.c.value)
+ ),
+ 1
+ )
+ eq_(
+ conn.scalar(
+ select([boolean_table.c.id]).where(
+ boolean_table.c.unconstrained_value)
+ ),
+ 1
+ )
+ eq_(
+ conn.scalar(
+ select([boolean_table.c.id]).where(~boolean_table.c.value)
+ ),
+ 2
+ )
+ eq_(
+ conn.scalar(
+ select([boolean_table.c.id]).where(
+ ~boolean_table.c.unconstrained_value)
+ ),
+ 2
+ )
+
+
+
class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
__requires__ = 'json_type',