Changeset 5260
- Timestamp:
- 05/16/07 11:48:36 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
r5254 r5260 536 536 # Casts dates into string format for entry into database. 537 537 if value is not None: 538 # MySQL /Oracle will throw a warning if microseconds are given, because539 # neither database supportsmicroseconds.540 if settings.DATABASE_ENGINE in ('mysql', 'oracle')and hasattr(value, 'microsecond'):538 # MySQL will throw a warning if microseconds are given, because it 539 # doesn't support microseconds. 540 if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): 541 541 value = value.replace(microsecond=0) 542 542 value = str(value) … … 544 544 545 545 def get_db_prep_lookup(self, lookup_type, value): 546 # Oracle will throw an error if microseconds are given, because it547 # doesn't support microseconds.548 if settings.DATABASE_ENGINE == 'oracle' and hasattr(value, 'microsecond'):549 value = value.replace(microsecond=0)550 546 if lookup_type == 'range': 551 547 value = [str(v) for v in value] … … 847 843 # MySQL will throw a warning if microseconds are given, because it 848 844 # doesn't support microseconds. 849 if settings.DATABASE_ENGINE in ('mysql', 'oracle')and hasattr(value, 'microsecond'):845 if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): 850 846 value = value.replace(microsecond=0) 851 if settings.DATABASE_ENGINE == 'oracle':847 elif settings.DATABASE_ENGINE == 'oracle': 852 848 # cx_Oracle expects a datetime.datetime to persist into TIMESTAMP field. 853 849 if isinstance(value, datetime.time): 854 value = datetime.datetime(1900, 1, 1, value.hour, value.minute, value.second) 850 value = datetime.datetime(1900, 1, 1, value.hour, value.minute, 851 value.second, value.microsecond) 855 852 elif isinstance(value, basestring): 856 853 value = datetime.datetime(*(time.strptime(value, '%H:%M:%S')[:6]))
