Fixed #3151 -- Improved MySQL backend not to send 'SET NAMES utf8' before every query. Thanks for the patch, smurf@smurf.noris.de

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-12-30 07:21:01 +00:00
parent 7180207328
commit f21cbb40b2
2 changed files with 6 additions and 3 deletions

View file

@ -98,9 +98,11 @@ class DatabaseWrapper(local):
kwargs['port'] = int(settings.DATABASE_PORT)
kwargs.update(self.options)
self.connection = Database.connect(**kwargs)
cursor = self.connection.cursor()
if self.connection.get_server_info() >= '4.1':
cursor.execute("SET NAMES 'utf8'")
cursor = self.connection.cursor()
if self.connection.get_server_info() >= '4.1':
cursor.execute("SET NAMES 'utf8'")
else:
cursor = self.connection.cursor()
if settings.DEBUG:
return util.CursorDebugWrapper(MysqlDebugWrapper(cursor), self)
return cursor