#22551: Oracle backend using bytes in isoformat
----------------------------------------------+----------------------------
     Reporter:  fatal10110@…                  |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.6
     Severity:  Normal                        |   Keywords:  oracle
 Triage Stage:  Unreviewed                    |  isoformat dates
Easy pickings:  1                             |  Has patch:  0
                                              |      UI/UX:  0
----------------------------------------------+----------------------------
 Hi , seems like we have some micro bug here, using oracle + django-celery
 :


 {{{
  File "-/site-packages/django/db/backends/oracle/base.py", line 449, in
 year_lookup_bounds_for_datetime_field
     return [b.isoformat(b' ') for b in bounds]

   File "-/site-packages/django/db/backends/oracle/base.py", line 449, in
 <listcomp>
     return [b.isoformat(b' ') for b in bounds]

 TypeError: isoformat() argument 1 must be a unicode character, not bytes
 }}}

 The reason of the excetion is "date_hierarchy" in admin part of django-
 celery


 {{{
 date_hierarchy = 'tstamp'
 }}}


 But it should work , beacause in models all is fine


 {{{
 tstamp = models.DateTimeField(_('event received at'), db_index=True)
 }}}

 From django documentation: " Set date_hierarchy to the name of a DateField
 or '''DateTimeField''' in your model, and the change list page will
 include a date-based drilldown navigation by that field."

 The code in oracle/base.py


 {{{
 def year_lookup_bounds_for_datetime_field(self, value):
         # The default implementation uses datetime objects for the bounds.
         # This must be overridden here, to use a formatted date (string)
 as
         # 'second' instead -- cx_Oracle chops the fraction-of-second part
         # off of datetime objects, leaving almost an entire second out of
         # the year under the default implementation.
         bounds = super(DatabaseOperations,
 self).year_lookup_bounds_for_datetime_field(value)
         if settings.USE_TZ:
             bounds = [b.astimezone(timezone.utc).replace(tzinfo=None) for
 b in bounds]
         return [b.isoformat(b' ') for b in bounds]

 }}}

 Example from python documentantion of how to use the isoformat() method:


 {{{
 datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')
 }}}


 They are not using '''b''' to convert the seperator to bytes..

 Should I remove the b or it's important ?

 Thanks.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22551>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.c94cd2619396f600e6d248cf44eea487%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to