Ticket #7190: mysql.patch

File mysql.patch, 1.2 KB (added by Pim Van Heuven, 16 years ago)
  • django/db/backends/mysql/base.py

    diff -ur -x.svn -x.mo -x'*.pyc' /home/pim/software/newforms/newforms-admin-7684/django/db/backends/mysql/base.py django/db/backends/mysql/base.py
    old new  
    33
    44Requires MySQLdb: http://sourceforge.net/projects/mysql-python
    55"""
    6 
     6import types
    77from django.db.backends import BaseDatabaseWrapper, BaseDatabaseFeatures, BaseDatabaseOperations, util
    88try:
    99    import MySQLdb as Database
     
    3939# TIME columns as timedelta -- they are more like timedelta in terms of actual
    4040# behavior as they are signed and include days -- and Django expects time, so
    4141# we still need to override that.
     42
     43def mysql_typecast_boolean(s):
     44    if s is None: return None
     45    return int(s) == 1
     46
    4247django_conversions = conversions.copy()
    4348django_conversions.update({
     49    types.BooleanType: util.rev_typecast_boolean,
     50    FIELD_TYPE.TINY: mysql_typecast_boolean,
    4451    FIELD_TYPE.TIME: util.typecast_time,
    4552    FIELD_TYPE.DECIMAL: util.typecast_decimal,
    4653    FIELD_TYPE.NEWDECIMAL: util.typecast_decimal,
Back to Top