]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- mssql VARBINARY emits 'max' for length when no length specified, as is
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Feb 2011 20:22:07 +0000 (15:22 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Feb 2011 20:22:07 +0000 (15:22 -0500)
the case already for VARCHAR, NVARCHAR [ticket:1833]

CHANGES
lib/sqlalchemy/dialects/mssql/base.py
test/dialect/test_mssql.py

diff --git a/CHANGES b/CHANGES
index 11b65b6f8ac11808c6866b04af8eae3bc5a2b1c6..e3682d688540407d371749b9966ff4a6d71278f8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -220,9 +220,14 @@ CHANGES
 - mssql
   - the String/Unicode types, and their counterparts VARCHAR/
     NVARCHAR, emit "max" as the length when no length is 
-    specified.   This makes it more compatible with Postgresql's
-    VARCHAR type which is similarly unbounded when no length
-    specified.
+    specified, so that the default length, normally '1' 
+    as per SQL server documentation, is instead
+    'unbounded'.  This also occurs for the VARBINARY type.
+    [ticket:1833].
+
+    This behavior makes these types more closely compatible 
+    with Postgresql's VARCHAR type which is similarly unbounded 
+    when no length is specified.
 
 - mysql
   - New DBAPI support for pymysql, a pure Python port
index 0faa970777d7e29992d825b287f2fe50275128df..c7fd20068f2069e2836ac6f600e7f40b80134be7 100644 (file)
@@ -604,6 +604,12 @@ class MSTypeCompiler(compiler.GenericTypeCompiler):
     def visit_IMAGE(self, type_):
         return "IMAGE"
 
+    def visit_VARBINARY(self, type_):
+        return self._extend(
+                        "VARBINARY", 
+                        type_, 
+                        length=type_.length or 'max')
+
     def visit_boolean(self, type_):
         return self.visit_BIT(type_)
 
index 42d3cdcd1e708f28a67f61c50e12b6cae6f6ca3d..fbefcfed9219091512e5d4c90604488f233b6fe8 100644 (file)
@@ -1284,14 +1284,14 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables):
              'BINARY(10)'),
 
             (mssql.MSVarBinary, [], {},
-             'VARBINARY'),
+             'VARBINARY(max)'),
             (mssql.MSVarBinary, [10], {},
              'VARBINARY(10)'),
 
-            (types.VARBINARY, [], {},
-             'VARBINARY'),
             (types.VARBINARY, [10], {},
              'VARBINARY(10)'),
+            (types.VARBINARY, [], {},
+             'VARBINARY(max)'),
 
             (mssql.MSImage, [], {},
              'IMAGE'),