Author: bouldersprinters
Date: 2007-04-17 14:19:38 -0500 (Tue, 17 Apr 2007)
New Revision: 5021
Modified:
django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
django/branches/boulder-oracle-sprint/django/db/models/query.py
django/branches/boulder-oracle-sprint/django/utils/tzinfo.py
Log:
boulder-oracle-sprint: Non-functional changes to bring the branch closer to the
current state of the trunk.
Modified:
django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
2007-04-17 16:56:13 UTC (rev 5020)
+++ django/branches/boulder-oracle-sprint/django/db/models/fields/__init__.py
2007-04-17 19:19:38 UTC (rev 5021)
@@ -494,15 +494,12 @@
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if settings.DATABASE_ENGINE != 'oracle':
- if isinstance(value, datetime.datetime):
- value = value.date().strftime('%Y-%m-%d')
- elif isinstance(value, datetime.date):
- value = value.strftime('%Y-%m-%d')
- else:
+ if settings.DATABASE_ENGINE == 'oracle':
# cx_Oracle needs a conversion to datetime.datetime instead.
if isinstance(value, datetime.date):
value = datetime.datetime.combine(value, datetime.time())
+ elif value is not None:
+ value = value.strftime('%Y-%m-%d')
return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
@@ -825,11 +822,14 @@
Field.__init__(self, verbose_name, name, **kwargs)
def get_db_prep_lookup(self, lookup_type, value):
- def prep(value):
- if settings.DATABASE_ENGINE == 'oracle' and isinstance(value,
datetime.time):
- # Oracle requires a date in order to parse.
- value = datetime.datetime.combine(datetime.date(1900, 1, 1),
value)
- return str(value)
+ if settings.DATABASE_ENGINE == 'oracle':
+ # Oracle requires a date in order to parse.
+ def prep(value):
+ if isinstance(value, datetime.time):
+ value = datetime.datetime.combine(datetime.date(1900, 1,
1), value)
+ return str(value)
+ else:
+ prep = str
if lookup_type == 'range':
value = [prep(v) for v in value]
else:
@@ -849,15 +849,13 @@
if value is not None:
# MySQL will throw a warning if microseconds are given, because it
# doesn't support microseconds.
- if settings.DATABASE_ENGINE == 'mysql' and hasattr(value,
'microsecond'):
+ if settings.DATABASE_ENGINE in ('mysql', 'oracle') and
hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
- value = str(value)
- elif settings.DATABASE_ENGINE == 'oracle':
- if hasattr(value, 'microsecond'):
- value = value.replace(microsecond=0)
- # cx_Oracle expects a datetime.datetime to persist into
TIMESTAMP field.
+ if settings.DATABASE_ENGINE == 'oracle':
+ # cx_Oracle expects a datetime.datetime to persist into
TIMESTAMP field.
+ if isinstance(value, datetime.time):
value = datetime.datetime(1900, 1, 1, value.hour,
value.minute, value.second)
- else:
+ elif isinstance(value, basestring):
value = datetime.datetime(*(time.strptime(value,
'%H:%M:%S')[:6]))
else:
value = str(value)
Modified: django/branches/boulder-oracle-sprint/django/db/models/query.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/db/models/query.py
2007-04-17 16:56:13 UTC (rev 5020)
+++ django/branches/boulder-oracle-sprint/django/db/models/query.py
2007-04-17 19:19:38 UTC (rev 5021)
@@ -5,7 +5,9 @@
from django.dispatch import dispatcher
from django.utils.datastructures import SortedDict
from django.conf import settings
-import datetime, operator, re
+import datetime
+import operator
+import re
# For Python 2.3
if not hasattr(__builtins__, 'set'):
Modified: django/branches/boulder-oracle-sprint/django/utils/tzinfo.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/utils/tzinfo.py
2007-04-17 16:56:13 UTC (rev 5020)
+++ django/branches/boulder-oracle-sprint/django/utils/tzinfo.py
2007-04-17 19:19:38 UTC (rev 5021)
@@ -46,7 +46,7 @@
return time.tzname[self._isdst(dt)]
def _isdst(self, dt):
- tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, 0, 0,
-1)
+ tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.weekday(), 0, -1)
stamp = time.mktime(tt)
tt = time.localtime(stamp)
return tt.tm_isdst > 0
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---