Django and SQL Server - Error when charfield > 10 chars
I'm using Django 1.2.3 and django-pyodbc.
I am receiving an error when adding a user with length > 10chars:
The data types nvarchar and ntext are incompatible in the equal to operator
Whenever I add a user with username of 10 characters or below it works fine, same error for emails.
Any idea folks?
The user table:
CREATE TABLE [auth_user] ( [id] int IDENTITY (1, 1) NOT NULL PRIMARY KEY, [username] nvarchar(30) NOT NULL UNIQUE, [first_name] nvarchar(30) NOT NULL, [last_name] nvarchar(30) NOT NULL, [email] nvarchar(75) NOT NULL, [password] nvarchar(128) NOT NULL, [is_staff] bit NOT NULL, [is_active] bit NOT NULL, [is_superuser] bit NOT NULL, [last_login] datetime NOT NULL, [date_joined] datetime NOT NULL )
I had a similar problem with SQL Server 2008 and the SQL Native Client odbc driver. Upgrading to SQL Server 2008 R2 fixed the problem. It seemed to be caused by an issue with the results from the SQLGetTypeInfo() odbc call for the WVARCHAR type including some date/time types too.
Try python manage.py sqlall <appname> to see what the definition of CREATE TABLE for your table.