Ticket #16808: 16808.patch

File 16808.patch, 1.4 KB (added by Aymeric Augustin, 13 years ago)
  • django/db/backends/util.py

    diff -r dd6ad9af49f4 django/db/backends/util.py
    a b  
    102102    return datetime.datetime(int(dates[0]), int(dates[1]), int(dates[2]),
    103103        int(times[0]), int(times[1]), int(seconds), int((microseconds + '000000')[:6]))
    104104
    105 def typecast_boolean(s):
    106     if s is None: return None
    107     if not s: return False
    108     return str(s)[0].lower() == 't'
    109 
    110105def typecast_decimal(s):
    111106    if s is None or s == '':
    112107        return None
     
    116111# Converters from Python to database (string) #
    117112###############################################
    118113
    119 def rev_typecast_boolean(obj, d):
    120     return obj and '1' or '0'
    121 
    122114def rev_typecast_decimal(d):
    123115    if d is None:
    124116        return None
  • tests/regressiontests/db_typecasts/tests.py

    diff -r dd6ad9af49f4 tests/regressiontests/db_typecasts/tests.py
    a b  
    4242        ('2010-10-12 15:29:22.0632021', datetime.datetime(2010, 10, 12, 15, 29, 22, 63202)),
    4343        ('2010-10-12 15:29:22.0632029', datetime.datetime(2010, 10, 12, 15, 29, 22, 63202)),
    4444    ),
    45     'typecast_boolean': (
    46         (None, None),
    47         ('', False),
    48         ('t', True),
    49         ('f', False),
    50         ('x', False),
    51     ),
    5245}
    5346
    5447class DBTypeCasts(unittest.TestCase):
Back to Top