Ticket #2763: django-mysql-zero-typcast-ticket2763.patch
File django-mysql-zero-typcast-ticket2763.patch, 1.4 KB (added by , 18 years ago) |
---|
-
django/db/backends/mysql/base.py
17 17 18 18 DatabaseError = Database.DatabaseError 19 19 20 def typecast_mysql_timestamp(s): 21 # workaround mysql issue. 22 # see http://code.djangoproject.com/ticket/433, 2763 and 2369 23 if s == "0000-00-00 00:00:00": 24 # an empty timestamp field. In MySQL, a *real* NULL field 25 # means NOW 26 return None 27 return util.typecast_timestamp(s) 28 29 def typecast_mysql_date(s): 30 # workaround mysql issue. 31 # see http://code.djangoproject.com/ticket/433, 2763 and 2369 32 if s == "0000-00-00": 33 # an empty timestamp field. In MySQL, a *real* NULL field 34 # means NOW 35 return None 36 return util.typecast_date(s) 37 20 38 django_conversions = conversions.copy() 21 39 django_conversions.update({ 22 40 types.BooleanType: util.rev_typecast_boolean, 23 FIELD_TYPE.DATETIME: util.typecast_timestamp,24 FIELD_TYPE.DATE: util.typecast_date,41 FIELD_TYPE.DATETIME: typecast_mysql_timestamp, 42 FIELD_TYPE.DATE: typecast_mysql_date, 25 43 FIELD_TYPE.TIME: util.typecast_time, 26 44 }) 27 45 46 28 47 # This should match the numerical portion of the version numbers (we can treat 29 48 # versions like 5.0.24 and 5.0.24a as the same). Based on the list of version 30 49 # at http://dev.mysql.com/doc/refman/4.1/en/news.html and