diff options
author | Michael Trier <mtrier@gmail.com> | 2008-12-28 21:07:57 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-12-28 21:07:57 +0000 |
commit | 8669eda82dcc84b726ab420106dfea86fc8a066f (patch) | |
tree | 840ddf45cbb376ee6753e1a7f278d471cf869d9b /lib/sqlalchemy/databases/mssql.py | |
parent | 7009653aa1c53d1f761501522d55617d3fdcc57c (diff) | |
download | sqlalchemy-8669eda82dcc84b726ab420106dfea86fc8a066f.tar.gz |
Added in a new MSGenericBinary type.
This maps to the Binary type so it can implement the specialized behavior of
treating length specified types as fixed-width Binary types and non-length
types as an unbound variable length Binary type.
Diffstat (limited to 'lib/sqlalchemy/databases/mssql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 0844745de..4d2176f85 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -676,7 +676,23 @@ class MSNChar(_StringType, sqltypes.NCHAR): return self._extend("NCHAR") -class MSBinary(sqltypes.Binary): +class MSGenericBinary(sqltypes.Binary): + """The Binary type assumes that a Binary specification without a length + is an unbound Binary type whereas one with a length specification results + in a fixed length Binary type. + + If you want standard MSSQL ``BINARY`` behavior use the ``MSBinary`` type. + + """ + + def get_col_spec(self): + if self.length: + return "BINARY(%s)" % self.length + else: + return "IMAGE" + + +class MSBinary(MSGenericBinary): def get_col_spec(self): if self.length: return "BINARY(%s)" % self.length @@ -684,7 +700,7 @@ class MSBinary(sqltypes.Binary): return "BINARY" -class MSVarBinary(MSBinary): +class MSVarBinary(MSGenericBinary): def get_col_spec(self): if self.length: return "VARBINARY(%s)" % self.length @@ -692,7 +708,7 @@ class MSVarBinary(MSBinary): return "VARBINARY" -class MSImage(MSBinary): +class MSImage(MSGenericBinary): def get_col_spec(self): return "IMAGE" @@ -720,22 +736,27 @@ class MSBoolean(sqltypes.Boolean): return value and True or False return process + class MSTimeStamp(sqltypes.TIMESTAMP): def get_col_spec(self): return "TIMESTAMP" + class MSMoney(sqltypes.TypeEngine): def get_col_spec(self): return "MONEY" + class MSSmallMoney(MSMoney): def get_col_spec(self): return "SMALLMONEY" + class MSUniqueIdentifier(sqltypes.TypeEngine): def get_col_spec(self): return "UNIQUEIDENTIFIER" + class MSVariant(sqltypes.TypeEngine): def get_col_spec(self): return "SQL_VARIANT" @@ -851,7 +872,7 @@ class MSSQLDialect(default.DefaultDialect): sqltypes.Date : MSDate, sqltypes.Time : MSTime, sqltypes.String : MSString, - sqltypes.Binary : MSBinary, + sqltypes.Binary : MSGenericBinary, sqltypes.Boolean : MSBoolean, sqltypes.Text : MSText, sqltypes.UnicodeText : MSNText, |