<p dir="auto"><strong>Migrated issue, originally created by Asher Leon Manning (<a href="https://github.com/A-Manning">@A-Manning</a>)</strong></p>
<p dir="auto">At line 2523 in sqlalchemy\sql\compiler ,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="text += &quot;(%d)&quot; % type_.length"><pre class="notranslate"><code class="notranslate">text += "(%d)" % type_.length
</code></pre></div>
<p dir="auto">causes a TypeError, as the '%d' expects a number, not 'max'</p>
<p dir="auto"><strong>Migrated issue, originally created by adridg (<a href="https://github.com/adridg">@adridg</a>)</strong></p>
<p dir="auto">With SQL Server, you can create columns of type VARCHAR(MAX). This is the modern rendition of NTEXT or TEXT, and SQL Alchemy translates String() into VARCHAR(MAX). With SQL Server 2012 or later, this happens automatically, and it's described in <a href="http://docs.sqlalchemy.org/en/latest/changelog/changelog_10.html#change-f520106ec3455eaa056110c048aa4862" rel="nofollow">http://docs.sqlalchemy.org/en/latest/changelog/changelog_10.html#change-f520106ec3455eaa056110c048aa4862</a> .</p>
<p dir="auto">However, on reflection (through the inspector) you can end up with a VARCHAR (sql type-)object that has a length of "max" (i.e. a string). Printing that object causes an exception. As a very simple and contrived example:</p>
<p dir="auto">from sqlalchemy import VARCHAR<br>
print VARCHAR()<br>
print VARCHAR(80)<br>
print VARCHAR("max")  # Fails in _render_type_string</p>
<p dir="auto">Attached find a simple test program that creates a table with a String() column, then reflects it to discover the VARCHAR(MAX) column.</p>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/3504/t.py">t.py</a></p>