Ticket #2763: django-mysql-zero-typcast-ticket2763.patch

File django-mysql-zero-typcast-ticket2763.patch, 1.4 KB (added by wam-djangobug@…, 18 years ago)

alternative patch which limits change to only affecting the mysql backend.

  • django/db/backends/mysql/base.py

     
    1717
    1818DatabaseError = Database.DatabaseError
    1919
     20def 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
     29def 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
    2038django_conversions = conversions.copy()
    2139django_conversions.update({
    2240    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,
    2543    FIELD_TYPE.TIME: util.typecast_time,
    2644})
    2745
     46
    2847# This should match the numerical portion of the version numbers (we can treat
    2948# versions like 5.0.24 and 5.0.24a as the same). Based on the list of version
    3049# at http://dev.mysql.com/doc/refman/4.1/en/news.html and
Back to Top