Opened 6 years ago

Last modified 6 years ago

#27544 closed Bug

F() Expressions updating dates in .update() field fails — at Version 1

Reported by: Gary Graham Owned by: nobody
Component: Database layer (models, ORM) Version: 1.10
Severity: Normal Keywords: F()
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Upon upgrading from 1.8 -> 1.10, I noticed that some code I had written now threw an error. Specifically, attempting to update datetime field's via F expression.

Branch with test showing regression ->

Bisected to ed83881e648771d22658f21b939f66e75c499864: Fixed #23820 -- Supported per-database time zone.

Stacktrace from failure:

ERROR: test_F_expression_fails (timezones.test_regression.ProveRegression)
Traceback (most recent call last):
  File "/home/tadgh/Projects/django/tests/timezones/", line 22, in test_F_expression_fails
  File "/home/tadgh/Projects/django/django/db/models/", line 585, in refresh_from_db
    db_instance = db_instance_qs.get()
  File "/home/tadgh/Projects/django/django/db/models/", line 381, in get
    num = len(clone)
  File "/home/tadgh/Projects/django/django/db/models/", line 240, in __len__
  File "/home/tadgh/Projects/django/django/db/models/", line 1061, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/tadgh/Projects/django/django/db/models/", line 68, in __iter__
    for row in compiler.results_iter(results):
  File "/home/tadgh/Projects/django/django/db/models/sql/", line 806, in results_iter
    row = self.apply_converters(row, converters)
  File "/home/tadgh/Projects/django/django/db/models/sql/", line 790, in apply_converters
    value = converter(value, expression, self.connection, self.query.context)
  File "/home/tadgh/Projects/django/django/db/backends/sqlite3/", line 159, in convert_datetimefield_value
    value = timezone.make_aware(value, self.connection.timezone)
  File "/home/tadgh/Projects/django/django/utils/", line 364, in make_aware
    return timezone.localize(value, is_dst=is_dst)
  File "/home/tadgh/.venvs/django_env/lib/python3.4/site-packages/pytz/", line 227, in localize
    raise ValueError('Not naive datetime (tzinfo is already set)')
ValueError: Not naive datetime (tzinfo is already set)

Change History (1)

comment:1 Changed 6 years ago by Tim Graham

Component: UncategorizedDatabase layer (models, ORM)
Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top