summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-26 10:46:34 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-09-26 10:46:34 +0000
commit4e76727fec2fa898314b4525a39ce995692f2a78 (patch)
tree894bb1f7e0781307a6599f890c67650f9038edff /django/db
parent5371ee1743dcfc6322dafeb292618c0405c00510 (diff)
Fixed #2188 -- Raise an error when using long CharFields in combination with
older MySQL versions. Thanks, Fraser Nevett <mail@nevett.org> . git-svn-id: http://code.djangoproject.com/svn/django/trunk@3855 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/mysql/base.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 23ea76316f..e266ad9101 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -13,6 +13,7 @@ except ImportError, e:
from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE
import types
+import re
DatabaseError = Database.DatabaseError
@@ -24,6 +25,8 @@ django_conversions.update({
FIELD_TYPE.TIME: util.typecast_time,
})
+server_version_re = re.compile('[.-]')
+
# This is an extra debug layer over MySQL queries, to display warnings.
# It's only used when DEBUG=True.
class MysqlDebugWrapper:
@@ -61,6 +64,7 @@ class DatabaseWrapper(local):
def __init__(self):
self.connection = None
self.queries = []
+ self.server_version = None
def _valid_connection(self):
if self.connection is not None:
@@ -110,6 +114,14 @@ class DatabaseWrapper(local):
self.connection.close()
self.connection = None
+ def get_server_version(self):
+ if not self.server_version:
+ if not self._valid_connection():
+ self.cursor()
+ version = server_version_re.split(self.connection.get_server_info())
+ self.server_version = tuple([int(x) for x in version[:3]]) + tuple(version[3:])
+ return self.server_version
+
supports_constraints = True
def quote_name(name):