gisserver.parsers.query module¶
The intermediate query result used by the various build_...() methods.
- class gisserver.parsers.query.CompiledQuery(feature_types: list[FeatureType], lookups: list[Q] | None = None, typed_lookups: dict[str, list[Q]] | None = None, annotations: dict[str, Combinable | Q] | None = None)¶
Bases:
objectIntermediate data for translating FES queries to Django.
This class effectively contains all data from the
<fes:Filter>object, but using a format that can be translated to a Django QuerySet.As the Abstract Syntax Tree of a FES-filter creates the ORM query, it fills this object with all intermediate bits. This allows building the final QuerySet object in a single round. Each
build_...()method in the tree may add extra lookups and annotations.- __init__(feature_types: list[FeatureType], lookups: list[Q] | None = None, typed_lookups: dict[str, list[Q]] | None = None, annotations: dict[str, Combinable | Q] | None = None)¶
- Parameters:
feature_types – The feature types this query uses. Typically, this is one feature unless a JOIN syntax is used.
The extra parameters of the init method ar typically used only in unit tests.
- add_annotation(value: Combinable | Q) str¶
Create a named-alias for a function/Q object. This alias can be used in a comparison, where expressions are used as left-hand-side.
- add_distinct()¶
Enforce “SELECT DISTINCT” on the query, used when joining 1-N or N-M relationships.
- add_extra_lookup(q_object: Q)¶
Temporary stash an extra lookup that the expression can’t return yet. This is used for XPath selectors that also filter on attributes, e.g. “element[@attr=..]/child”. The attribute lookup is processed as another filter.
- add_lookups(q_object: Q, type_name: str | None = None)¶
Register an extra ‘WHERE’ clause of the query. This is used for comparisons, ID selectors and other query types.
- apply_extra_lookups(comparison: Q) Q¶
Combine stashed lookups with the provided Q object.
This is called for functions that compile a “Q” object. In case a node added extra lookups (for attributes), these are combined here with the actual comparison.
- mark_empty()¶
Mark as returning no results.