Hi Carl, 2015-04-13 21:11 GMT+02:00 Carl Meyer <[email protected] <mailto:[email protected]>>: It would also be possible to put the silent-data-loss aspect of this change through a deprecation path, by having the existing adapters raise a deprecation warning on receiving any non-UTC aware datetime for a couple releases (presuming the ORM is updated to always send only UTC, the adapter should only receive non-UTC on direct cursor.execute()).
I have implemented this. It works and I think that's the best compromise for backwards compatibility. https://github.com/django/django/pull/4601 <https://github.com/django/django/pull/4601> There are a few side effects for adapters — the Python => DB side — but I find them acceptable considering the small cross section of people who will be affected by this change. >From 1.4 to 1.8, on SQLite and MySQL, Django has raised a warning when receiving a naive datetime. 1.9 and 2.0 will raise a warning when receiving an aware datetime. That isn't very nice to our users. Writing backend-independent code becomes a bit tricky. In the case we're discussing here, passing naive datetimes in UTC regardless of whether the backend supports time zones should work. As far as I can tell, the PostgreSQL backend won't complain, even though it's designed for aware datetimes. If users take advantage of the ability to configure the time zone for a given database, the shim won't work correctly. Since it's global, it doesn't know about the current connection. It's hardcoded to use UTC. Overall I find it logical that connection.cursor() be unaffected by Django's time zone management. If we follow this line of thought, we can ask why the PostgreSQL backend adds the UTC tzinfo at the level of the cursor. Is that worth changing? I've brough up that question in the pull request comments. -- Aymeric. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" 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]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/900F4B38-9CD6-4726-8769-ACD3587593BD%40polytechnique.org. For more options, visit https://groups.google.com/d/optout.
