diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-17 13:05:04 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-17 17:08:23 -0400 |
| commit | 912fb6c2d54d7f2fcda654a8f7702d122e8b8d70 (patch) | |
| tree | bc9fb26d88acc7631fce8eacbfd90d53253f2584 /lib/sqlalchemy/orm | |
| parent | 4c6917e1d68a8baab7efe10e9ce5e5c8187f65ca (diff) | |
| download | sqlalchemy-912fb6c2d54d7f2fcda654a8f7702d122e8b8d70.tar.gz | |
Add new configuration, inspection for baked queries
Added new flag :paramref:`.Session.enable_baked_queries` to the
:class:`.Session` to allow baked queries to be disabled
session-wide, reducing memory use. Also added new :class:`.Bakery`
wrapper so that the bakery returned by :paramref:`.BakedQuery.bakery`
can be inspected.
Change-Id: I5657af7a99d2b24c89d6aee1343f432728e3f807
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/session.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 3585166f4..6186ac4f7 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -588,6 +588,7 @@ class Session(_SessionClassMethods): _enable_transaction_accounting=True, autocommit=False, twophase=False, weak_identity_map=True, binds=None, extension=None, + enable_baked_queries=True, info=None, query_cls=query.Query): r"""Construct a new Session. @@ -661,6 +662,21 @@ class Session(_SessionClassMethods): :class:`.sessionmaker` function, and is not sent directly to the constructor for ``Session``. + :param enable_baked_queries: defaults to ``True``. A flag consumed + by the :mod:`sqlalchemy.ext.baked` extension to determine if + "baked queries" should be cached, as is the normal operation + of this extension. When set to ``False``, all caching is disabled, + including baked queries defined by the calling application as + well as those used internally. Setting this flag to ``False`` + can significantly reduce memory use, however will also degrade + performance for those areas that make use of baked queries + (such as relationship loaders). Additionally, baked query + logic in the calling application or potentially within the ORM + that may be malfunctioning due to cache key collisions or similar + can be flagged by observing if this flag resolves the issue. + + .. versionadded:: 1.2 + :param _enable_transaction_accounting: Defaults to ``True``. A legacy-only flag which when ``False`` disables *all* 0.5-style object accounting on transaction boundaries, including auto-expiry @@ -735,6 +751,7 @@ class Session(_SessionClassMethods): self.autoflush = autoflush self.autocommit = autocommit self.expire_on_commit = expire_on_commit + self.enable_baked_queries = enable_baked_queries self._enable_transaction_accounting = _enable_transaction_accounting self.twophase = twophase self._query_cls = query_cls |
