diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-13 20:03:48 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-13 20:03:48 -0400 |
| commit | 11003828cb65693f6b85818552cab652d8ae1294 (patch) | |
| tree | 65b65f6f53f16790666720f083d84e47f440245c /lib/sqlalchemy/sql | |
| parent | 9c5c12fb230cc72bf5ae8573dc420007718eaf0a (diff) | |
| download | sqlalchemy-11003828cb65693f6b85818552cab652d8ae1294.tar.gz | |
- Added support for literal rendering of boolean values, e.g.
"true" / "false" or "1" / "0".
- added Boolean tests to the test suite
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index ec1d66459..f3468ebc2 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1274,6 +1274,15 @@ class Boolean(TypeEngine, SchemaType): def python_type(self): 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) + return process + def bind_processor(self, dialect): if dialect.supports_native_boolean: return None |
