summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py6
-rw-r--r--test/dialect/test_mssql.py6
3 files changed, 17 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 11b65b6f8..e3682d688 100644
--- 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
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 0faa97077..c7fd20068 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -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_)
diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py
index 42d3cdcd1..fbefcfed9 100644
--- a/test/dialect/test_mssql.py
+++ b/test/dialect/test_mssql.py
@@ -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'),