#26183: Postgres backend: Time Field is created without time zone, cascading
problems when changing this
-------------------------------------+-------------------------------------
     Reporter:  schtibe              |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  Database layer       |    Version:  1.8
  (models, ORM)                      |   Keywords:  postgres, timezone,
     Severity:  Normal               |  time field
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 The documentation states that "The PostgreSQL backend stores datetimes as
 timestamp with time zone."
 Sadly, it does not do that with the TimeField, which can easily be seen in
 db/backend/postgres_psycopg2/base.py line 97. In my opinion, it would be
 nice to have the same behaviour for both the DateTimeField and the
 TimeField.

 It's easy to change this line to

 {{{
         'TimeField': 'time with time zone'
 }}}

 which does work. But there is a problem:
 I wanted to do a pull request so I changed the line. Now I had problems
 with my migrations file, since I have one that alters a field from
 TimeField (which was now "with time zone") to a interval. Postgres does
 not like that and throws

 {{{
         django.db.utils.ProgrammingError: column "duration" cannot be cast
 automatically to type interval
         HINT:  You might need to specify "USING duration::interval".
 }}}

 So I did that and executed, by hand:

 {{{
         ALTER TABLE "resource_check_testtyperesourcetype" ALTER COLUMN
 "duration" TYPE interval USING duration::interval;
 }}}

 Now it says: '''ERROR:  cannot cast type time with time zone to interval
 at character 103'''

 So now I'm not sure if it is even a good idea to change the default
 behaviour of TimeField to "with time zone"....

--
Ticket URL: <https://code.djangoproject.com/ticket/26183>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.9978beaa8ed89fcf87ebf576f4f5c712%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to