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_1_0~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d92f79fd86073203a2a956460140c311c85a396;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Document how SQL Server does MAX with VARCHAR, NVARCHAR Fixes #3760 Change-Id: I0613eb66bfdc9d7118688c74e29c8da322c3b4db --- diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index bc1ad5cdf3..d1c7452a17 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -166,6 +166,26 @@ how SQLAlchemy handles this: This is an auxilliary use case suitable for testing and bulk insert scenarios. +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 -----------------