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 sqlall <appname> to see what the definition of CREATE TABLE for your table.

Need Your Help

Is it safe for structs to implement interfaces?

c# interface struct

I seem to remember reading something about how it is bad for structs to implement interfaces in CLR via C#, but I can't seem to find anything about it. Is it bad? Are there unintended consequence...

INSERT IGNORE Inserting 0 rows

sql mysql insert rows ignore

When I am attempting to run "INSERT IGNORE ..." in MYSQL to add only one variable to a table of several options, after the first insert, it refuses to work. It says "Inserted rows: 0" and doesn't ...