Ticket #4287: inf-bug.patch
File inf-bug.patch, 1.2 KB (added by , 14 years ago) |
---|
-
django/db/backends/mysql/base.py
43 43 DatabaseError = Database.DatabaseError 44 44 IntegrityError = Database.IntegrityError 45 45 46 def Float2Str(value, conv): 47 if value == float('inf'): 48 return '2147483647' 49 elif value == float('-inf'): 50 return '-2147483648' 51 else: 52 return conversions[float](value, conv) 53 54 def mysql_float_converter(value): 55 if value == '2147483647': 56 return float('inf') 57 elif value == '-2147483648': 58 return float('-inf') 59 else: 60 return float(value) 61 46 62 # MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like 47 63 # timedelta in terms of actual behavior as they are signed and include days -- 48 64 # and Django expects time, so we still need to override that. We also need to … … 53 69 FIELD_TYPE.TIME: util.typecast_time, 54 70 FIELD_TYPE.DECIMAL: util.typecast_decimal, 55 71 FIELD_TYPE.NEWDECIMAL: util.typecast_decimal, 72 float: Float2Str, 73 FIELD_TYPE.DOUBLE: mysql_float_converter, 56 74 }) 57 75 58 76 # This should match the numerical portion of the version numbers (we can treat