Changeset 31
- Timestamp:
- 03/12/07 20:21:31
- Files:
-
- trunk/geniusql/adapters.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/geniusql/adapters.py
r30 r31 185 185 186 186 def coerce_datetime_timedelta_to_any(self, value): 187 float_val = value.days + (value.seconds / 86400.0)188 return repr( float_val)187 dec_val = (value.days * 86400) + value.seconds 188 return repr(dec_val) 189 189 190 190 coerce_decimal_to_any = str … … 232 232 def _to_TEXT(self, value): 233 233 return "'%s'" % str(value) 234 235 def add_pickled_type(self, pytype): 236 name = "coerce_%s_to_any" % getCoerceName(pytype) 237 setattr(self, name, self.do_pickle) 238 234 239 235 240 for fromtype in ('decimal', 'decimal_Decimal', 'fixedpoint_FixedPoint', … … 291 296 292 297 def coerce_any_to_datetime_timedelta(self, value): 293 days, seconds = divmod( value, 1)294 return datetime.timedelta( days, int(seconds * 86400))298 days, seconds = divmod(long(value), 86400) 299 return datetime.timedelta(int(days), int(seconds)) 295 300 296 301 def coerce_any_to_decimal(self, value): … … 337 342 else: 338 343 return unicode(value, self.encoding) 344 345 def add_pickled_type(self, pytype): 346 name = "coerce_any_to_%s" % getCoerceName(pytype) 347 setattr(self, name, self.do_pickle) 339 348 340 349 … … 494 503 def coerce_datetime_time(self, col): return "TIME" 495 504 496 # I was seriously disinterested in writing a parser for interval.505 # Use decimal instead of float to avoid rounding errors. 497 506 def coerce_datetime_timedelta(self, col): 498 return self. coerce_float(col)507 return self.int_type(self.numeric_max_bytes) 499 508 500 509 def decimal_type(self, colname, precision, scale): … … 553 562 return self.coerce_long(col) 554 563 return self.int_type(bytes) 555 564 565 def add_pickled_type(self, pytype): 566 name = "coerce_%s" % getCoerceName(pytype) 567 setattr(self, name, self.coerce_str) 568
