Repository navigation
Proof of Concept for single lookup on HyperlinkRelatedField - #5150
carltongibson wants to merge 1 commit into
Conversation
160e203 to
e811365
Compare
|
This is all quiet, so I expect there's no imminent follow-up. (That's OK). Question: do we want to handle to this case in core? i.e. do we want to jump through the hoops to ensure a single lookup? There are ≈6 |
|
First pass: 🤷♂️ 💭 ? Gonna need to get deeper into this another day. |
Was thinking about closing both of these off as I wasn't entirely happy with the correctness check. (Around ln 570) I'm worried about missing edge-cases and introducing hard to maintain errors there. For me it's a question of "what's in scope?" now. |
|
As things stand I'd probably push this into "known constraint" territory, unless we could simplify things. 🤷♂️ No great answers here. |
I know the POC here isn't that simple — in that I didn't tidy anything up — but the underlying idea is fairly straightforward (I think):
This is what A completed PR, on these two points, should be clean enough. (I'd hope) The third step:
... seems harder. A simple set comparison may be enough but I'm not (as yet) convinced there aren't all number of ways that may go wrong. (Though perhaps it is that simple...?)
Exactly :-) I wonder if it's worth making I haven't got the bandwidth to take this on right now. I'll close this and related for now. It's something I may return to (although I'm more likely to cache the lookup first so...) |
|
Thanks @carltongibson - wish there was a more obvious best-way-forward here. |
Ref #4917 and #5093 by @orf, hoping to advance the discussion there.
Proof of Concept. Do Not Merge
This just shows how a single-lookup for
HyperlinkRelatedFieldwould look like inManyRelatedField.There's no attempt to make it look pretty.
The idea (from #5093) is that
RelatedFieldsubclasses add alookup_parametersparameters method returning a dict that looks ≈like:or
This is
lookup_fieldandlookup_value.Here
ManyRelatedFieldmaps a list of lookups to a single__inlookup and validates that thelenof the requested and returned sets match.If something like this were adopted
to_internal_valueon non-many fields would uselookup_parametersas-is to feed into thegetcall.