diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-07-13 01:12:53 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-07-13 01:12:53 +0000 |
commit | 2cb2b624f97a88df857777104cc0db6d733306ef (patch) | |
tree | cef1a31e792e5b3adb36e6efc9f0b47ac15a3c5e /lib | |
parent | 7cb8f04f48eed7afd5befe2ce00ea3771ea79b40 (diff) | |
download | sqlalchemy-2cb2b624f97a88df857777104cc0db6d733306ef.tar.gz |
fixed up boolean datatype for sqlite, mysql, ms-sql
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 13 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 17 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/sqlite.py | 4 |
3 files changed, 32 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 89cc88398..c297195ca 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -143,6 +143,19 @@ class MSBinary(sqltypes.Binary): class MSBoolean(sqltypes.Boolean): def get_col_spec(self): return "BIT" + def convert_result_value(self, value, dialect): + if value is None: + return None + return value and True or False + def convert_bind_param(self, value, dialect): + if value is True: + return 1 + elif value is False: + return 0 + elif value is None: + return None + else: + return value and True or False colspecs = { sqltypes.Integer : MSInteger, diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index e152a4833..997010f1c 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -157,7 +157,7 @@ class MSBinary(sqltypes.Binary): return "BINARY(%d)" % self.length else: return "BLOB" - def convert_result_value(self, value, engine): + def convert_result_value(self, value, dialect): if value is None: return None else: @@ -182,7 +182,20 @@ class MSEnum(sqltypes.String): class MSBoolean(sqltypes.Boolean): def get_col_spec(self): return "BOOLEAN" - + def convert_result_value(self, value, dialect): + if value is None: + return None + return value and True or False + def convert_bind_param(self, value, dialect): + if value is True: + return 1 + elif value is False: + return 0 + elif value is None: + return None + else: + return value and True or False + colspecs = { # sqltypes.BIGinteger : MSInteger, sqltypes.Integer : MSInteger, diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index 2b10a8ad9..c07952ff2 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -79,6 +79,10 @@ class SLBinary(sqltypes.Binary): class SLBoolean(sqltypes.Boolean): def get_col_spec(self): return "BOOLEAN" + def convert_result_value(self, value, dialect): + if value is None: + return None + return value and True or False colspecs = { sqltypes.Integer : SLInteger, |