diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-30 18:06:07 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-30 18:06:46 -0400 |
| commit | 888f112b78e1cabc73eb410ecd8133df7b5cb957 (patch) | |
| tree | c687a5a86f36f74d09ddcc1b5c43d56956835431 /lib/sqlalchemy/sql | |
| parent | 22396493b26f18780eb51fce874dd2435a83a0e5 (diff) | |
| download | sqlalchemy-888f112b78e1cabc73eb410ecd8133df7b5cb957.tar.gz | |
Enable native boolean for SQL Server
SQL Server supports what SQLAlchemy calls "native boolean"
with its BIT type, as this type only accepts 0 or 1 and the
DBAPIs return its value as True/False. So the SQL Server
dialects now enable "native boolean" support, in that a
CHECK constraint is not generated for a :class:`.Boolean`
datatype. The only difference vs. other native boolean
is that there are no "true" / "false" constants so "1" and
"0" are still rendered here.
Tests are implicit in the existing suites.
Change-Id: I75bbcd549884099fb1a177e68667bf880c40fa7c
Fixes: #4061
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index fe9a56b6e..d0dbc4881 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1603,12 +1603,12 @@ class Boolean(TypeEngine, SchemaType): return bool def literal_processor(self, dialect): - if dialect.supports_native_boolean: - def process(value): - return "true" if value else "false" - else: - def process(value): - return str(1 if value else 0) + compiler = dialect.statement_compiler(dialect, None) + true = compiler.visit_true(None) + false = compiler.visit_false(None) + + def process(value): + return true if value else false return process def bind_processor(self, dialect): |
