Changes between Initial Version and Version 1 of Ticket #34871, comment 10


Ignore:
Timestamp:
Feb 22, 2024, 1:17:34 AM (9 months ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34871, comment 10

    initial v1  
    55It's doable but certainly not trivial [https://github.com/charettes/django/pull/new/ticket-34871 as this branch demonstrate].
    66
    7 I think this has some ties into #24267 where the idea would be that we'd introduce an `UnresolvedLookup(BaseExpression)` class initialized from `__init__(self, field, **lookup)` and that would store `F(field)` in its source expressions and thus allow `replace_expressions` to take place normally as `Q` would be storing `UnresolvedLookup(key_parts[0], key_parts[1:])` instead of tuple of the form `tuple[str, Any]` as children. All `UnresolvedLookup` would do in its `resolve_expressions` is what can be found in the trailing part of `Query.build_filter` today that calls `solve_lookup_type`, `resolve_lookup_value`, and `build_lookup` but it would behave like a normal expression and avoids all the hacks we have in place today that special case `Q` objects.
     7I think this has some ties into #24267 where the idea would be that we'd introduce an `UnresolvedLookup(BaseExpression)` class initialized from `__init__(self, field, **lookup)` and that would store `F(field)` in its source expressions and thus allow `replace_expressions` to take place normally as `Q` would be storing `UnresolvedLookup(key_parts[0], key_parts[1:])` instead of tuple of the form `tuple[str, Any]` as children.
     8
     9All `UnresolvedLookup` would do in its `resolve_expressions` is what can be found in the trailing part of `Query.build_filter` today that calls `solve_lookup_type`, `resolve_lookup_value`, and `build_lookup` but it would behave like a normal expression and avoids all the hacks we have in place today that special case `Q` objects.
    810
    911Until work towards ^^ can be made the best solution here is to use lookups directly
Back to Top