[Django] #28492: output_field in __init__-method of expressions

7 views
Skip to first unread message

Django

unread,
Aug 13, 2017, 11:18:19 AM8/13/17
to django-...@googlegroups.com
#28492: output_field in __init__-method of expressions
-------------------------------------+-------------------------------------
Reporter: Mads | Owner: nobody
Jensen |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
There are a few expression-classes that override `__init__` just to set
`output_field`,

{{{
class Extent3D(GeoAggregate):

def __init__(self, expression, **extra):
super().__init__(expression, output_field=ExtentField(), **extra)
}}}

From this comment
https://github.com/django/django/pull/7611/files#r131567089 `runtests.py`
needs to be adjusted, so it's possible to use a class-variable for the
output field instead.

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

Django

unread,
Aug 13, 2017, 11:38:18 AM8/13/17
to django-...@googlegroups.com
#28492: Allow defining expressions' default output_field as a class attribute
rather than in __init__()
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* cc: Simon Charette (added)
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Simon has a [https://github.com/django/django/pull/8872 PR] for this.

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

Django

unread,
Sep 11, 2017, 1:56:04 PM9/11/17
to django-...@googlegroups.com
#28492: Allow defining expressions' default output_field as a class attribute
rather than in __init__()
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

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


Comment:

In [changeset:"08654a99bbdd09049d682ae57cc94241534b29f0" 08654a99]:
{{{
#!CommitTicketReference repository=""
revision="08654a99bbdd09049d682ae57cc94241534b29f0"
Fixed #28492 -- Defined default output_field of expressions at the class
level.

This wasn't possible when settings were accessed during Field
initialization
time as our test suite setup script was triggering imports of expressions
before settings were configured.
}}}

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

Django

unread,
Sep 11, 2017, 1:56:04 PM9/11/17
to django-...@googlegroups.com
#28492: Allow defining expressions' default output_field as a class attribute
rather than in __init__()
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

In [changeset:"13be45308045f522dfd1d0ff3da3cdc163bc521d" 13be4530]:
{{{
#!CommitTicketReference repository=""
revision="13be45308045f522dfd1d0ff3da3cdc163bc521d"
Refs #28492 -- Stopped accessing settings at Field.db_tablespace
initialization.

Deferring accesses to settings allows database fields to be initialized
before
settings are loaded.
}}}

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

Django

unread,
Sep 29, 2017, 8:34:15 AM9/29/17
to django-...@googlegroups.com
#28492: Allow defining expressions' default output_field as a class attribute
rather than in __init__()
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

In [changeset:"f1b713024e3a1e8c6361ea407cb8248224f7cc82" f1b7130]:
{{{
#!CommitTicketReference repository=""
revision="f1b713024e3a1e8c6361ea407cb8248224f7cc82"
Refs #28492 -- Defined aggregates' output_field at the class level.

Missed in 08654a99bbdd09049d682ae57cc94241534b29f0.
}}}

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

Django

unread,
Sep 29, 2017, 8:34:15 AM9/29/17
to django-...@googlegroups.com
#28492: Allow defining expressions' default output_field as a class attribute
rather than in __init__()
-------------------------------------+-------------------------------------
Reporter: Mads Jensen | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

In [changeset:"deb3b58b362ef393b49702a3fef28774c9c3f53e" deb3b58b]:
{{{
#!CommitTicketReference repository=""
revision="deb3b58b362ef393b49702a3fef28774c9c3f53e"
[2.0.x] Refs #28492 -- Defined aggregates' output_field at the class
level.

Missed in 08654a99bbdd09049d682ae57cc94241534b29f0.

Backport of f1b713024e3a1e8c6361ea407cb8248224f7cc82 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages