OData¶
qgendapy.odata
¶
OData()
¶
Builder for OData query parameters.
Supports method chaining::
params = OData().select("Name", "Email").filter("IsActive eq true").to_params()
QGenda's API speaks OData v4 (Microsoft.AspNet.OData), not the older v2
dialect. The two are mostly compatible for $select, $filter equality,
$orderby, and $expand, but a handful of functions changed names:
+-------------------+-----------------------------+----------------------------+
| Operation | OData v2 (rejected, 400) | OData v4 (works) |
+===================+=============================+============================+
| Substring search | substringof('X', Name) | contains(Name, 'X') |
+-------------------+-----------------------------+----------------------------+
| Starts-with | startswith(Name, 'X') | startswith(Name, 'X') |
+-------------------+-----------------------------+----------------------------+
Always prefer the v4 form when writing $filter expressions for QGenda.
Source code in src/qgendapy/odata.py
escape_literal(value)
¶
Escape a string literal for safe interpolation into an OData $filter.
OData v4 escapes single quotes inside string literals by doubling them. Use this on any value that might contain a quote before substituting it into a filter expression — e.g.::
odata = OData().filter(f"StaffKey eq '{escape_literal(staff_key)}'")
Source code in src/qgendapy/odata.py
merge_expand(expand, odata)
¶
Merge an expand= shortcut into an existing :class:OData builder.
Returns odata unchanged when expand is None. When expand is
provided, returns a new :class:OData that preserves every other param
from odata and concatenates the new nav properties onto any
existing $expand (comma-joined). Use this so callers can pass both
odata=OData().expand("Tags") and expand="Skillset" without
silently dropping one.