[Django] #31368: Missing documentation for `from_db_value`

13 views
Skip to first unread message

Django

unread,
Mar 16, 2020, 10:14:39 AM3/16/20
to django-...@googlegroups.com
#31368: Missing documentation for `from_db_value`
-------------------------------------+-------------------------------------
Reporter: Paolo | Owner: nobody
Lammens |
Type: | Status: new
Cleanup/optimization |
Component: | Version: 3.0
Documentation | Keywords: documentation,
Severity: Normal | missing
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The documentation on the semantics and usage for the `expression`
parameter in the
[https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.Field.from_db_value
`from_db_value` converter] is nowhere to be found.

The only two places that mention this method are the
[https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.Field.from_db_value
Model field reference] and the
[https://docs.djangoproject.com/en/3.0/howto/custom-model-fields
/#converting-values-to-python-objects "Writing custom model fields"
guide], but neither mention what `expression` is or how it should be used.

In fact, there is no specification for `value` or `connection` either, but
at least the meaning of these parameters can be inferred.


See also: https://stackoverflow.com/q/60560775/6117426

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

Django

unread,
Mar 17, 2020, 1:54:45 AM3/17/20
to django-...@googlegroups.com
#31368: Document from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Accepted
missing |
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


Comment:

Django uses backend and field/expression converters. `expression` is a
field or an expression and it's used by backend converters. All converters
have the same signature that's why we keep the `expression` parameter in
`Field.from_db_value()` and `Expression.convert_value()` signatures even
if for them it's the same as `self`.

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

Django

unread,
Mar 17, 2020, 1:55:31 AM3/17/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.

-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Accepted
missing |
Has patch: 0 | Needs documentation: 0

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

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

Django

unread,
Mar 17, 2020, 6:59:13 PM3/17/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Accepted
missing |
Has patch: 1 | Needs documentation: 0

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

* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1


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

Django

unread,
Mar 17, 2020, 7:02:01 PM3/17/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Accepted
missing |
Has patch: 1 | Needs documentation: 0

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

Comment (by Hasan Ramezani):

I've created a [https://github.com/django/django/pull/12582 PR].
Just added @felixxm [https://code.djangoproject.com/ticket/31368#comment:1
comment] to documentation.
Please let me know if there is something to be improved.

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

Django

unread,
Mar 18, 2020, 2:31:18 AM3/18/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 3.0
Severity: Normal | Resolution:
Keywords: documentation, | Triage Stage: Ready for
missing | checkin
Has patch: 1 | Needs documentation: 0

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

* easy: 0 => 1
* stage: Accepted => Ready for checkin


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

Django

unread,
Mar 18, 2020, 6:57:37 AM3/18/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.0
Severity: Normal | Resolution: fixed

Keywords: documentation, | Triage Stage: Ready for
missing | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"6929f13254ce42b0a4ee5d677591d47b61023ae7" 6929f132]:
{{{
#!CommitTicketReference repository=""
revision="6929f13254ce42b0a4ee5d677591d47b61023ae7"
Fixed #31368 -- Doc'd 'expression' parameter of
Field.from_db_value()/Expression.convert_value().
}}}

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

Django

unread,
Mar 18, 2020, 6:57:54 AM3/18/20
to django-...@googlegroups.com
#31368: Document Field.from_db_value()'s "expression" parameter.
-------------------------------------+-------------------------------------
Reporter: Paolo Lammens | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed
Component: Documentation | Version: 3.0
Severity: Normal | Resolution: fixed
Keywords: documentation, | Triage Stage: Ready for
missing | checkin
Has patch: 1 | Needs documentation: 0

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

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"aea93441399176128a6d7e67bf65aa0533b3026f" aea93441]:
{{{
#!CommitTicketReference repository=""
revision="aea93441399176128a6d7e67bf65aa0533b3026f"
[3.0.x] Fixed #31368 -- Doc'd 'expression' parameter of
Field.from_db_value()/Expression.convert_value().

Backport of 6929f13254ce42b0a4ee5d677591d47b61023ae7 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages