- changed component to sql
- changed title to handle the "max" symbol for (unknown database) ?
- marked as major
- changed milestone to 1.x.xx
add VARCHAR, NVARCHAR placeholder types to SQL Server dialect, support first class compilation
At line 2523 in sqlalchemy\sql\compiler ,
text += "(%d)" % type_.length
causes a TypeError, as the '%d' expects a number, not 'max'
Comments (12)
-
repo owner -
reporter I encountered the bug with SQL Server 2008, but 'max' is allowed in all versions of SQL Server since 2005.
-
reporter - changed title to handle the "max" symbol for SQL Server?
-
repo owner If this is SQL Server, please use sqlalchemy.dialects.mssql.VARCHAR() and don't specify a length.
-
repo owner - changed component to mssql
- changed title to add CompileError and documentation for SQL Server VARCHAR types + MAX
- changed milestone to 1.0.xx
-
reporter It should not be necessary to make modifications to a database to use SQLAlchemy on it.
The error was encountered in the following code
connectstring = ('mssql+pyodbc:///?odbc_connect=DRIVER.....') title = 'table_title' en = sqlalchemy.create_engine(connectstring) md= sqlalchemy.MetaData() table = sqlalchemy.Table('%s' %title, md, autoload=True, autoload_with=en) for c in table.columns: print c.type
If the database contains a column of type Integer(max) or Varchar(max), etc, it will throw this error.
-
repo owner ah! a code sample illustrating a bug ! well that is different! moment
-
repo owner -
repo owner - changed milestone to 1.1
- changed title to add VARCHAR, NVARCHAR placeholder types to SQL Server dialect, support first class compilation
the SQL Server dialect does not contain VARCHAR or NVARCHAR at all, as "max" is not part of its implementation. so this disables the ability to select for the right compiler.
-
repo owner OK nevermind, this was handled differently as part of
#3504. that is, we don't leak the "max" detail into the type. -
repo owner - changed status to duplicate
Duplicate of
#3504. -
repo owner please use:
print repr(c.type)
or:
from sqlalchemy.dialects import mssql print c.type.compile(dialect=mssql.dialect())
until you can upgrade to 1.1.
- Log in to comment
please specify what database backend you are targeting.
reference: https://gerrit.sqlalchemy.org/#/c/19/
needs tests if someone has resources to contribute