Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21146 closed Bug (fixed)

DatabaseCache doesn't work if database backend returns datetime values as strings

Reported by: Michael Manfre Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Normal Keywords: DatabaseCache
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

DatabaseCache intentionally uses cursors and converts all datetimes to naive values. This is a problem for database backends that return datetimes from the database as strings that must be converted to a datetime before being used. All reads of the expires column should be passed through DatabaseOperations.convert_values, and timezone.make_naive to maintain the current naive-only datetimes behavior.

Change History (3)

comment:1 by Michael Manfre, 11 years ago

Has patch: set

https://github.com/django/django/pull/1676

Patch uses typecast_timestamp and checks existing DatabaseFeature.needs_datetime_string_cast to match behavior of SQLCompiler without using too much of the ORM.

comment:2 by Anssi Kääriäinen <akaariai@…>, 11 years ago

Resolution: fixed
Status: newclosed

In d5606b57637f00c4349732d79541faa41acfe29c:

Fixed #21146 - DatabaseCache converts expires to python value

DatabaseCache uses raw cursors to bypass the ORM. This prevents it from
being used by database backends that require special handling of datetime
values.

There is no easy way to test this, so no tests added.

comment:3 by Anssi Kääriäinen <akaariai@…>, 11 years ago

In a979a2fea5415849773fdfb37765ffedef6f50f2:

[1.6.x] Fixed #21146 - DatabaseCache converts expires to python value

DatabaseCache uses raw cursors to bypass the ORM. This prevents it from
being used by database backends that require special handling of datetime
values.

There is no easy way to test this, so no tests added.

Backport of d5606b5763 from master

Note: See TracTickets for help on using tickets.
Back to Top