[Django] #27544: F() Expressions updating dates in .update() field fails

16 vues
Accéder directement au premier message non lu

Django

non lue,
28 nov. 2016, 12:21:5728/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails
-----------------------------------------+------------------------
Reporter: Gary Graham | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords: F()
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

Bisect log, about 3000 commits back -> https://dpaste.de/HGYb

Branch with test showing regression ->
https://github.com/tadgh/django/commit/c31133261c68b10525b8e3b34e6895a0c6ece4d0

Apparent first commit where regression occurs ->
https://github.com/django/django/pull/4601/commits/ed83881e648771d22658f21b939f66e75c499864

Stacktrace from failure -> https://dpaste.de/DkSV

--
Ticket URL: <https://code.djangoproject.com/ticket/27544>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

non lue,
28 nov. 2016, 12:28:1628/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails
-------------------------------------+-------------------------------------

Reporter: Gary Graham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:

Keywords: F() | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => Database layer (models, ORM)


Old description:

> 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.
>
> Bisect log, about 3000 commits back -> https://dpaste.de/HGYb
>
> Branch with test showing regression ->
> https://github.com/tadgh/django/commit/c31133261c68b10525b8e3b34e6895a0c6ece4d0
>
> Apparent first commit where regression occurs ->
> https://github.com/django/django/pull/4601/commits/ed83881e648771d22658f21b939f66e75c499864
>
> Stacktrace from failure -> https://dpaste.de/DkSV

New description:

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 ->
https://github.com/tadgh/django/commit/c31133261c68b10525b8e3b34e6895a0c6ece4d0

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/test_regression.py",
line 22, in test_F_expression_fails
self.timestamp.refresh_from_db()
File "/home/tadgh/Projects/django/django/db/models/base.py", line 585,
in refresh_from_db
db_instance = db_instance_qs.get()
File "/home/tadgh/Projects/django/django/db/models/query.py", line 381,
in get
num = len(clone)
File "/home/tadgh/Projects/django/django/db/models/query.py", line 240,
in __len__
self._fetch_all()
File "/home/tadgh/Projects/django/django/db/models/query.py", line 1061,
in _fetch_all
self._result_cache = list(self.iterator())
File "/home/tadgh/Projects/django/django/db/models/query.py", line 68,
in __iter__
for row in compiler.results_iter(results):
File "/home/tadgh/Projects/django/django/db/models/sql/compiler.py",
line 806, in results_iter
row = self.apply_converters(row, converters)
File "/home/tadgh/Projects/django/django/db/models/sql/compiler.py",
line 790, in apply_converters
value = converter(value, expression, self.connection,
self.query.context)
File
"/home/tadgh/Projects/django/django/db/backends/sqlite3/operations.py",
line 159, in convert_datetimefield_value
value = timezone.make_aware(value, self.connection.timezone)
File "/home/tadgh/Projects/django/django/utils/timezone.py", 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/__init__.py", line 227, in localize
raise ValueError('Not naive datetime (tzinfo is already set)')
ValueError: Not naive datetime (tzinfo is already set)
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:1>

Django

non lue,
28 nov. 2016, 13:15:1128/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------

Reporter: Gary Graham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

The regression seems limited to SQLite. If you could provide a patch, we
can backport to 1.10. Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:2>

Django

non lue,
28 nov. 2016, 13:34:5328/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------

Reporter: Gary Graham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Gary Graham):

Replying to [comment:2 Tim Graham]:


> The regression seems limited to SQLite. If you could provide a patch, we
can backport to 1.10. Thanks.

OK, but I have no clue where to even start looking. I will start tracing,
but if you could give me a reasonable starting point, I would appreciate
it. The first time I ever opened the Django repo was to submit this bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:3>

Django

non lue,
28 nov. 2016, 13:46:3528/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------

Reporter: Gary Graham | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

In the `sqlite3/operations.py` file referenced in the traceback, it might
be enough to check the `datetime` using `django.utils.timezone.is_aware()`
and skip the `timezone.make_aware()` call if appropriate.

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:4>

Django

non lue,
29 nov. 2016, 07:01:1429/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: assigned

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrew Nester):

* owner: nobody => Andrew Nester
* status: new => assigned


Comment:

I added pull request for this issue
[https://github.com/django/django/pull/7630 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:5>

Django

non lue,
29 nov. 2016, 12:03:2129/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:6>

Django

non lue,
29 nov. 2016, 12:23:5929/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: closed

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ade52ef71f04e57e217585358cb289098260e3ec" ade52ef7]:
{{{
#!CommitTicketReference repository=""
revision="ade52ef71f04e57e217585358cb289098260e3ec"
Fixed #27544 -- Fixed QuerySet.update(dt=F('dt') + timedelta) crash on
SQLite.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:7>

Django

non lue,
29 nov. 2016, 12:30:4129/11/2016
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: closed
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"75de55f1f381880348ad5215e15604a83f8971a5" 75de55f1]:
{{{
#!CommitTicketReference repository=""
revision="75de55f1f381880348ad5215e15604a83f8971a5"
[1.10.x] Fixed #27544 -- Fixed QuerySet.update(dt=F('dt') + timedelta)
crash on SQLite.

Backport of ade52ef71f04e57e217585358cb289098260e3ec from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:8>

Django

non lue,
16 janv. 2017, 07:22:1316/01/2017
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: closed
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Florian Klink):

I also got hit by this one. I backported the commit to the stable/1.9.x
branch, you can find my [https://github.com/django/django/pull/7855 PR]
here.

Replying to [comment:8 Tim Graham <timograham@…>]:


> In [changeset:"75de55f1f381880348ad5215e15604a83f8971a5" 75de55f1]:
> {{{
> #!CommitTicketReference repository=""
revision="75de55f1f381880348ad5215e15604a83f8971a5"
> [1.10.x] Fixed #27544 -- Fixed QuerySet.update(dt=F('dt') + timedelta)
crash on SQLite.
>
> Backport of ade52ef71f04e57e217585358cb289098260e3ec from master
> }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:9>

Django

non lue,
16 janv. 2017, 07:28:1516/01/2017
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: new
Component: Database layer | Version: 1.9

(models, ORM) |
Severity: Normal | Resolution:
Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Florian Klink):

* status: closed => new
* version: 1.10 => 1.9
* resolution: fixed =>


--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:10>

Django

non lue,
16 janv. 2017, 09:04:2916/01/2017
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: closed

Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Florian Klink):

* status: new => closed
* resolution: => wontfix


Comment:

The [https://github.com/django/django/pull/7855 PR] got rejected:

> As per our supported versions policy, 1.9 only receives security support
now (and will be unsupported in April upon the release of Django 1.11).

So I close this here again.

--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:11>

Django

non lue,
16 janv. 2017, 10:02:4516/01/2017
à django-...@googlegroups.com
#27544: F() Expressions updating dates in .update() field fails on SQLite
-------------------------------------+-------------------------------------
Reporter: Gary Graham | Owner: Andrew
| Nester
Type: Bug | Status: closed
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: F() | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* version: 1.9 => 1.10
* resolution: wontfix => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/27544#comment:12>

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message