:paramref:`_orm.Session.future` flag is set on :class:`_orm.sessionmaker`
or :class:`_orm.Session`.
+.. _error_s9r1:
+
+Object is being merged into a Session along the backref cascade
+---------------------------------------------------------------
+
+Backref cascades are being removed in SQLAlchemy 2.0. This is a behavior in
+which ORM relationships add objects to the session in a potentially
+surprising way.
+
+To get the 2.0 behavior, set the :paramref:`_orm.relationship.cascade_backrefs` and
+:paramref:`_orm.backref.cascade_backrefs` parameters.
+:paramref:`_orm.relationship.backref` values should be updated from strings, if
+used, to :func:`~.sqlalchemy.orm.backref` function calls.
+
+For more details on the backref cascade, see the section
+:ref:`backref_cascade`. You can also read more about the deprecation and its
+rationale in the section :ref:`change_5150`.
+
Connections and Transactions
============================
.. _backref_cascade:
-.. _error_s9r1:
-
Controlling Cascade on Backrefs
-------------------------------
session until it's construction is completed, but still needs to be given
associations to objects which are already persistent in the target session.
-When relationships are created by the ``backref`` parameter to
-``relationship()``, ``cascade_backrefs=False`` can be set by using the
-``backref()`` function instead of a string. For example, the above relationship
+When relationships are created by the :paramref:`_orm.relationship.backref`
+parameter on :func:`_orm.relationship`, the :paramref:`_orm.cascade_backrefs`
+parameter may be set to ``False`` on the backref side by using the
+:func:`_orm.backref` function instead of a string. For example, the above relationship
could be declared::
mapper_registry.map_imperatively(Order, order_table, properties={
_version_token = None
-class _CodeStrMixin(object):
+class HasDescriptionCode:
"""helper which adds 'code' as an attribute and '_code_str' as a method"""
code = None
code = kw.pop("code", None)
if code is not None:
self.code = code
- super(_CodeStrMixin, self).__init__(*arg, **kw)
+ super(HasDescriptionCode, self).__init__(*arg, **kw)
def _code_str(self):
if not self.code:
)
-class SQLAlchemyError(_CodeStrMixin, Exception):
+class SQLAlchemyError(HasDescriptionCode, Exception):
"""Generic error class."""
def _message(self, as_unicode=compat.py3k):
# Warnings
-class SADeprecationWarning(_CodeStrMixin, DeprecationWarning):
+class SADeprecationWarning(HasDescriptionCode, DeprecationWarning):
"""Issued for usage of deprecated APIs."""
deprecated_since = None