diff -r dd6ad9af49f4 django/db/backends/util.py
a
|
b
|
|
102 | 102 | return datetime.datetime(int(dates[0]), int(dates[1]), int(dates[2]), |
103 | 103 | int(times[0]), int(times[1]), int(seconds), int((microseconds + '000000')[:6])) |
104 | 104 | |
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 | | |
110 | 105 | def typecast_decimal(s): |
111 | 106 | if s is None or s == '': |
112 | 107 | return None |
… |
… |
|
116 | 111 | # Converters from Python to database (string) # |
117 | 112 | ############################################### |
118 | 113 | |
119 | | def rev_typecast_boolean(obj, d): |
120 | | return obj and '1' or '0' |
121 | | |
122 | 114 | def rev_typecast_decimal(d): |
123 | 115 | if d is None: |
124 | 116 | return None |
diff -r dd6ad9af49f4 tests/regressiontests/db_typecasts/tests.py
a
|
b
|
|
42 | 42 | ('2010-10-12 15:29:22.0632021', datetime.datetime(2010, 10, 12, 15, 29, 22, 63202)), |
43 | 43 | ('2010-10-12 15:29:22.0632029', datetime.datetime(2010, 10, 12, 15, 29, 22, 63202)), |
44 | 44 | ), |
45 | | 'typecast_boolean': ( |
46 | | (None, None), |
47 | | ('', False), |
48 | | ('t', True), |
49 | | ('f', False), |
50 | | ('x', False), |
51 | | ), |
52 | 45 | } |
53 | 46 | |
54 | 47 | class DBTypeCasts(unittest.TestCase): |