WilliamRen / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

varchar([n]) fields are introspected as textfields without max_length #126

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Reproduce the problem:

1. add a field type varchar(8) to a table in SQL 2005
2. run django's inspectdb tool
3. behold the output where the varchar field in question will be a textfield 
with no max_length set

Using Django_pyodbc 1.4 on a Windows 7 machine

A VARCHAR([n]), like NVARCHAR([N]) should have a max_length property complying 
to the given lenght.
I have fixed this by simply changing:

"Database.SQL_VARCHAR:           'TextField'," 

to 

"Database.SQL_VARCHAR:           'CharField',"

in introspection.py.
I don't know if this is the most elegant solution.

Thanks,

Erik

Original issue reported on code.google.com by erik.oos...@gmail.com on 13 Jun 2012 at 2:08

GoogleCodeExporter commented 8 years ago
I got the same problem

Original comment by imgotop@gmail.com on 16 Mar 2014 at 4:43