popoto.backends.planning¶
popoto.backends.planning
¶
Compile a public query call into a protocol :class:QueryPlan (#759 M1b).
Query.filter/count hand a backend a :class:QueryPlan. The Redis
backend replays :attr:QueryPlan.source through its moved filter body, so for
Redis the query layer sends source alone, exactly as in M1a. Every other
backend compiles WHERE/ORDER BY from the plan's own terms, so for
those the query layer calls :func:plan_from_call, which populates
where, order_by, limit and project from the call -- and keeps
source for reference.
It reproduces, from the model's own filter vocabulary
(_meta.filter_query_params_by_field), what the Redis path decides:
- validation, with the same
QueryExceptiontext -- an unknown parameter or an unknown__operator(name__bogus) isInvalid filter parameters: …, never an exact match on a field of that name; a non-boolean__isnull; a malformed__between; a partitionedSortedFieldqueried without its partition; a non-tuplevalues=; anorder_bythat is not a field, or is missing fromvalues=. - ordering: explicit
order_by>Meta.order_by> the first filteredSortedField's score order (ZRANGEBYSCOREorder, which the Redis path uses when nothing else orders the result, and which survives asMeta.order_by's tie-break because Python's sort is stable). A descending primary term reverses the tie-breaks too, aslist(reversed(...))does. - plain fields: an unindexed field compared by equality, which Redis does
client-side after hydration, is an ordinary
Cond.
Pure -- no network, no backend driver -- with one exception: a chained
Relationship lookup (person__name="Alice") runs the related model's
own query to find the keys it matches, as Redis's filter_query does.
TRUE = And(())
module-attribute
¶
Matches everything (an empty Q()).
validity_cond(field_name, param, suffix, value)
¶
validity__as_of=t / validity__current=… (#759 M3), validated
as ValidityField.filter_query validates them -- the same
ValueError text -- and compiled to Cond(field, VALID_AT, (t,
valid)): valid is False only for __current=False, the
complement (members of either interval index not valid now).
Source code in src/popoto/backends/planning.py
plan_from_call(call)
¶
Validate call the way the query layer does and compile it.
Source code in src/popoto/backends/planning.py
has_filters(call)
¶
Whether call filters at all (anything beyond the result
modifiers, or a Q object).