Changeset 9467 for django/trunk/django/db/backends/mysql
- Timestamp:
- 11/16/08 02:50:06 (2 months ago)
- Files:
-
- django/trunk/django/db/backends/mysql/base.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/backends/mysql/base.py
r8802 r9467 30 30 from django.db.backends.mysql.introspection import DatabaseIntrospection 31 31 from django.db.backends.mysql.validation import DatabaseValidation 32 from django.utils.safestring import SafeString, SafeUnicode 32 33 33 34 # Raise exceptions for database warnings if DEBUG is on … … 40 41 IntegrityError = Database.IntegrityError 41 42 42 # MySQLdb-1.2.1 supports the Python boolean type, and only uses datetime 43 # module for time-related columns; older versions could have used mx.DateTime 44 # or strings if there were no datetime module. However, MySQLdb still returns 45 # TIME columns as timedelta -- they are more like timedelta in terms of actual 46 # behavior as they are signed and include days -- and Django expects time, so 47 # we still need to override that. 43 # MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like 44 # timedelta in terms of actual behavior as they are signed and include days -- 45 # and Django expects time, so we still need to override that. We also need to 46 # add special handling for SafeUnicode and SafeString as MySQLdb's type 47 # checking is too tight to catch those (see Django ticket #6052). 48 48 django_conversions = conversions.copy() 49 49 django_conversions.update({ … … 175 175 if value is None: 176 176 return None 177 177 178 178 # MySQL doesn't support tz-aware datetimes 179 179 if value.tzinfo is not None: … … 186 186 if value is None: 187 187 return None 188 188 189 189 # MySQL doesn't support tz-aware datetimes 190 190 if value.tzinfo is not None: 191 191 raise ValueError("MySQL backend does not support timezone-aware datetimes.") 192 192 193 193 # MySQL doesn't support microseconds 194 194 return unicode(value.replace(microsecond=0)) … … 261 261 kwargs.update(self.options) 262 262 self.connection = Database.connect(**kwargs) 263 self.connection.encoders[SafeUnicode] = self.connection.encoders[unicode] 264 self.connection.encoders[SafeString] = self.connection.encoders[str] 263 265 cursor = CursorWrapper(self.connection.cursor()) 264 266 return cursor
