Opened 5 years ago

Closed 5 years ago

Last modified 5 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, 5 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, 5 years ago

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

comment:3 by Hasan Ramezani, 5 years ago

Has patch: set
Owner: changed from nobody to Hasan Ramezani
Status: newassigned
Version 0, edited 5 years ago by Hasan Ramezani (next)

comment:4 by Hasan Ramezani, 5 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, 5 years ago

Easy pickings: set
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 5 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@…>, 5 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