class BakedQuery(object):
.query.Query
objects.Class Method | bakery |
Construct a new bakery. |
Method | add_criteria |
Add a criteria function to this .BakedQuery . |
Method | for_session |
Return a _baked.Result object for this .BakedQuery . |
Method | spoil |
Cancel any query caching that will occur on this BakedQuery object. |
Method | to_query |
Return the _query.Query object for use as a subquery. |
Method | with_criteria |
Add a criteria function to a .BakedQuery cloned from this one. |
Method | __add__ |
Undocumented |
Method | __call__ |
Undocumented |
Method | __iadd__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | _add_lazyload_options |
Used by per-state lazy loaders to add options to the "lazy load" query from a parent query. |
Method | _as_query |
Undocumented |
Method | _bake |
Undocumented |
Method | _clone |
Undocumented |
Method | _effective_key |
Return the key that actually goes into the cache dictionary for this .BakedQuery , taking into account the given .Session . |
Method | _retrieve_baked_query |
Undocumented |
Method | _update_cache_key |
Undocumented |
Method | _with_lazyload_options |
Cloning version of _add_lazyload_options. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | _bakery |
Undocumented |
Instance Variable | _cache_key |
Undocumented |
Instance Variable | _spoiled |
Undocumented |
Instance Variable | steps |
Undocumented |
Returns | |
an instance of .Bakery |
Add a criteria function to this .BakedQuery
.
This is equivalent to using the += operator to
modify a .BakedQuery
in-place.
Return a _baked.Result
object for this
.BakedQuery
.
This is equivalent to calling the .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.
Parameters | |
full | if False, only functions added to this
.BakedQuery object subsequent to the spoil step will be
non-cached; the state of the .BakedQuery up until
this point will be pulled from the cache. If True, then the
entire _query.Query object is built from scratch each
time, with all creational functions being called on each
invocation. |
Return the _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 .BakedQuery
. The
parameter should normally be the _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 .Session
, the .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()) )
Parameters | |
query_or_session | a
New in version 1.3.
|
Add a criteria function to a .BakedQuery
cloned from this
one.
This is equivalent to using the + operator to
produce a new .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 .BakedQuery
, taking into account the given
.Session
.
This basically means we also will include the session's query_class,
as the actual _query.Query
object is part of what's cached
and needs to match the type of _query.Query
that a later
session will want to use.