Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31368 closed Cleanup/optimization (fixed)

Document Field.from_db_value()'s "expression" parameter.

Reported by: Paolo Lammens Owned by: Hasan Ramezani
Component: Documentation Version: 3.0
Severity: Normal Keywords: documentation, missing
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The documentation on the semantics and usage for the expression parameter in the `from_db_value` converter is nowhere to be found.

The only two places that mention this method are the Model field reference and the "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

Change History (7)

comment:1 by Mariusz Felisiak, 4 years ago

Summary: Missing documentation for `from_db_value`Document from_db_value()'s "expression" parameter.
Triage Stage: UnreviewedAccepted

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.

comment:2 by Mariusz Felisiak, 4 years ago

Summary: Document from_db_value()'s "expression" parameter.Document Field.from_db_value()'s "expression" parameter.

comment:3 by Hasan Ramezani, 4 years ago

Has patch: set
Owner: changed from nobody to Hasan Ramezani
Status: newassigned
Last edited 4 years ago by Mariusz Felisiak (previous) (diff)

comment:4 by Hasan Ramezani, 4 years ago

I've created a PR.
Just added @felixxm comment to documentation.
Please let me know if there is something to be improved.

comment:5 by Mariusz Felisiak, 4 years ago

Easy pickings: set
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 6929f132:

Fixed #31368 -- Doc'd 'expression' parameter of Field.from_db_value()/Expression.convert_value().

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In aea93441:

[3.0.x] Fixed #31368 -- Doc'd 'expression' parameter of Field.from_db_value()/Expression.convert_value().

Backport of 6929f13254ce42b0a4ee5d677591d47b61023ae7 from master

Note: See TracTickets for help on using tickets.
Back to Top