The :paramref:`_orm.Session.flush.objects` parameter is now deprecated.
Fixes: #10816
Change-Id: I4a535e91aefa16774c2549ecec09113d6e669df4
--- /dev/null
+.. change::
+ :tags: usecase, orm
+ :tickets: 10816
+
+ The :paramref:`_orm.Session.flush.objects` parameter is now
+ deprecated.
\ No newline at end of file
particular objects may need to be operated upon before the
full flush() occurs. It is not intended for general use.
+ .. deprecated:: 2.1
+
""" # noqa: E501
from ..sql.schema import Table
from ..sql.selectable import ForUpdateArg
from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL
+from ..util import deprecated_params
from ..util import IdentitySet
from ..util.typing import Literal
from ..util.typing import TupleAny
particular objects may need to be operated upon before the
full flush() occurs. It is not intended for general use.
+ .. deprecated:: 2.1
+
"""
if self._flushing:
and not self._new
)
+ # have this here since it otherwise causes issues with the proxy
+ # method generation
+ @deprecated_params(
+ objects=(
+ "2.1",
+ "The `objects` parameter of `Session.flush` is deprecated",
+ )
+ )
def _flush(self, objects: Optional[Sequence[object]] = None) -> None:
dirty = self._dirty_states
if not dirty and not self._deleted and not self._new:
)
return fn(*args, **kwargs) # type: ignore[no-any-return]
- doc = fn.__doc__ is not None and fn.__doc__ or ""
+ doc = fn.__doc__ if fn.__doc__ is not None else ""
if doc:
doc = inject_param_text(
doc,
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import in_
from sqlalchemy.testing import not_in
+from sqlalchemy.testing.assertions import uses_deprecated
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.entities import ComparableEntity
from sqlalchemy.testing.fixtures import fixture_session
Column("parent_id", Integer, ForeignKey("parent.id")),
)
+ @uses_deprecated(
+ "The `objects` parameter of `Session.flush` is deprecated"
+ )
def test_o2m_m2o(self):
base, noninh_child = self.tables.base, self.tables.noninh_child
assert c2 in sess and c2 not in sess.new
assert b1 in sess and b1 in sess.new
+ @uses_deprecated(
+ "The `objects` parameter of `Session.flush` is deprecated"
+ )
def test_circular_sort(self):
"""test ticket 1306"""
s = fixture_session()
s.add(OK())
- x_raises_(s, "flush", objects=(user_arg,))
+ with assertions.expect_deprecated(
+ "The `objects` parameter of `Session.flush` is deprecated"
+ ):
+ x_raises_(s, "flush", objects=(user_arg,))
_()