﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2635	[patch] Updates for MySQL backend	Andy Dustman <farcepest@…>	Malcolm Tredinnick	"The patch (to be attached) is fairly heavily commented, and I intend to post a reference to this bug on django-users and encourage people to test it.

= Changes =

 * requires MySQLdb-1.2.1 and newer.
 * eliminates `MysqlDebugWrapper` in favor of the standard `util.CursorDebugWrapper` and using warning filtering to raise warnings as exceptions.
 * sets character set to UTF8 in the the connection initiation
 * returns non-binary character fields as unicode
 * sets the [http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html server SQL mode]
   * ANSI makes it more SQL standards-compliant, including use of double-quotes
   * TRADITIONAL mode turns warnings about bad values into errors

I've tested it with my own application and it seems to work fine. One gotcha I ran into that I actually get updates from an
external database, and the query string for that database needs strings and not unicodes, and I since I was now getting
unicode back from MySQL, I was trying to pass unicode to it, but that was easily fixed. Everything else in Django seems
to work fine for me with unicode.

= Concerns =

 * unicode values still might be breaking things; in this case, use_unicode=False should be set (charset implies 
   use_unicode=True) as a workaround, but the plan is to make Django unicode-safe anyway, as I understand it.
 * warning filtering may be redundant with TRADITIONAL mode, but not harmful.
 * sql_mode is being set for ANSI,TRADITIONAL. The last options is new to MySQL-5.0,
   and this may cause errors for MySQL-4.1, or it might be ignored; I have only had time to test on MySQL-5.0.
   ANSI works going back to 4.1. ANSI_QUOTES is recognized by MySQL-4.0. If need be I can add some version
   tests.

The real question is, what is the earliest version of MySQL you want to support? I think either 4.1 or 5.0 would be a reasonable
cutoff, as the current stable version is 5.0, and 5.1 is in late beta, and 4.1 adds the good character set support.
Originally when I did this, I copied the mysql backend and called it mysql5, but you may not want to have multiple
backends (though there is a precedence for that). Ultimately I think it needs to be left to the end-users to decide
what the minimum version should be, since the Django developers prefer PostgreSQL."	enhancement	closed	Database layer (models, ORM)	dev	normal	fixed		farcepest@…	Ready for checkin	1	0	0	0	0	0
