Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#21146 closed Bug (fixed)

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

Reported by: manfre Owned by: nobody
Component: Core (Cache system) Version: master
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 Changed 2 years ago by manfre

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 2 years ago by Anssi Kääriäinen <akaariai@…>

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 2 years ago by Anssi Kääriäinen <akaariai@…>

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