class BakedQuery: (source)
A builder object for :class:`.query.Query` objects.
Class Method | bakery |
Construct a new bakery. |
Method | __add__ |
Undocumented |
Method | __call__ |
Undocumented |
Method | __iadd__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | add |
Add a criteria function to this :class:`.BakedQuery`. |
Method | for |
Return a :class:`_baked.Result` object for this :class:`.BakedQuery`. |
Method | spoil |
Cancel any query caching that will occur on this BakedQuery object. |
Method | to |
Return the :class:`_query.Query` object for use as a subquery. |
Method | with |
Add a criteria function to a :class:`.BakedQuery` cloned from this one. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | steps |
Undocumented |
Method | _add |
Used by per-state lazy loaders to add options to the "lazy load" query from a parent query. |
Method | _as |
Undocumented |
Method | _bake |
Undocumented |
Method | _clone |
Undocumented |
Method | _effective |
Return the key that actually goes into the cache dictionary for this :class:`.BakedQuery`, taking into account the given :class:`.Session`. |
Method | _retrieve |
Undocumented |
Method | _update |
Undocumented |
Method | _with |
Cloning version of _add_lazyload_options. |
Instance Variable | _bakery |
Undocumented |
Instance Variable | _cache |
Undocumented |
Instance Variable | _spoiled |
Undocumented |
Add a criteria function to this :class:`.BakedQuery`. This is equivalent to using the ``+=`` operator to modify a :class:`.BakedQuery` in-place.
Return a :class:`_baked.Result` object for this :class:`.BakedQuery`. This is equivalent to calling the :class:`.BakedQuery` as a Python callable, e.g. ``result = my_baked_query(session)``.
Cancel any query caching that will occur on this BakedQuery object. The BakedQuery can continue to be used normally, however additional creational functions will not be cached; they will be called on every invocation. This is to support the case where a particular step in constructing a baked query disqualifies the query from being cacheable, such as a variant that relies upon some uncacheable value. :param full: if False, only functions added to this :class:`.BakedQuery` object subsequent to the spoil step will be non-cached; the state of the :class:`.BakedQuery` up until this point will be pulled from the cache. If True, then the entire :class:`_query.Query` object is built from scratch each time, with all creational functions being called on each invocation.
Return the :class:`_query.Query` object for use as a subquery. This method should be used within the lambda callable being used to generate a step of an enclosing :class:`.BakedQuery`. The parameter should normally be the :class:`_query.Query` object that is passed to the lambda:: sub_bq = self.bakery(lambda s: s.query(User.name)) sub_bq += lambda q: q.filter( User.id == Address.user_id).correlate(Address) main_bq = self.bakery(lambda s: s.query(Address)) main_bq += lambda q: q.filter( sub_bq.to_query(q).exists()) In the case where the subquery is used in the first callable against a :class:`.Session`, the :class:`.Session` is also accepted:: sub_bq = self.bakery(lambda s: s.query(User.name)) sub_bq += lambda q: q.filter( User.id == Address.user_id).correlate(Address) main_bq = self.bakery( lambda s: s.query( Address.id, sub_bq.to_query(q).scalar_subquery()) ) :param query_or_session: a :class:`_query.Query` object or a class :class:`.Session` object, that is assumed to be within the context of an enclosing :class:`.BakedQuery` callable. .. versionadded:: 1.3
Add a criteria function to a :class:`.BakedQuery` cloned from this one. This is equivalent to using the ``+`` operator to produce a new :class:`.BakedQuery` with modifications.
Used by per-state lazy loaders to add options to the "lazy load" query from a parent query. Creates a cache key based on given load path and query options; if a repeatable cache key cannot be generated, the query is "spoiled" so that it won't use caching.
Return the key that actually goes into the cache dictionary for this :class:`.BakedQuery`, taking into account the given :class:`.Session`. This basically means we also will include the session's query_class, as the actual :class:`_query.Query` object is part of what's cached and needs to match the type of :class:`_query.Query` that a later session will want to use.