From: Mike Bayer Date: Wed, 27 Jul 2016 14:04:52 +0000 (-0400) Subject: - Document how SQL Server does MAX with VARCHAR, NVARCHAR X-Git-Tag: rel_1_0_15~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9288d691f3a53f1ad68bd4493885cb3057e53e8c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Document how SQL Server does MAX with VARCHAR, NVARCHAR Fixes #3760 Change-Id: I0613eb66bfdc9d7118688c74e29c8da322c3b4db (cherry picked from commit 0d92f79fd86073203a2a956460140c311c85a396) --- diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 927dceff74..af93cc1c39 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -216,6 +216,25 @@ to either True or False. the SQL Server dialect's legacy behavior with schema-qualified table names. This flag will default to False in version 1.1. +MAX on VARCHAR / NVARCHAR +------------------------- + +SQL Server supports the special string "MAX" within the +:class:`.sqltypes.VARCHAR` and :class:`.sqltypes.NVARCHAR` datatypes, +to indicate "maximum length possible". The dialect currently handles this as +a length of "None" in the base type, rather than supplying a +dialect-specific version of these types, so that a base type +specified such as ``VARCHAR(None)`` can assume "unlengthed" behavior on +more than one backend without using dialect-specific types. + +To build a SQL Server VARCHAR or NVARCHAR with MAX length, use None:: + + my_table = Table( + 'my_table', metadata, + Column('my_data', VARCHAR(None)), + Column('my_n_data', NVARCHAR(None)) + ) + Collation Support -----------------