--- /dev/null
+.. change::
+ :tags: bug, orm
+ :tickets: 9913
+
+ The :attr:`_orm.InstanceState.unloaded_expirable` attribute is a synonym
+ for :attr:`_orm.InstanceState.unloaded`, and is now deprecated; this
+ attribute was always implementation-specific and should not have been
+ public.
if state._deleted:
del state._deleted
state._commit_all(state.dict)
- state._expire_attributes(state.dict, state.unloaded_expirable)
+ state._expire_attributes(state.dict, state.unloaded)
def object_session(instance: object) -> Optional[Session]:
def unloaded(self) -> Set[str]:
"""Return the set of keys which do not have a loaded value.
- This includes expired attributes and any other attribute that
- was never populated or modified.
+ This includes expired attributes and any other attribute that was never
+ populated or modified.
"""
return (
)
@property
+ @util.deprecated(
+ "2.0",
+ "The :attr:`.InstanceState.unloaded_expirable` attribute is "
+ "deprecated. Please use :attr:`.InstanceState.unloaded`.",
+ )
def unloaded_expirable(self) -> Set[str]:
- """Return the set of keys which do not have a loaded value.
+ """Synonymous with :attr:`.InstanceState.unloaded`.
- This includes expired attributes and any other attribute that
- was never populated or modified.
+ This attribute was added as an implementation-specific detail at some
+ point and should be considered to be private.
"""
return self.unloaded
from sqlalchemy import exc as sa_exc
from sqlalchemy import ForeignKey
from sqlalchemy import func
+from sqlalchemy import Identity
+from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import literal_column
from sqlalchemy import MetaData
class MiscDeprecationsTest(fixtures.TestBase):
+ def test_unloaded_expirable(self, decl_base):
+ class A(decl_base):
+ __tablename__ = "a"
+ id = mapped_column(Integer, Identity(), primary_key=True)
+ x = mapped_column(
+ Integer,
+ )
+ y = mapped_column(Integer, deferred=True)
+
+ decl_base.metadata.create_all(testing.db)
+ with Session(testing.db) as sess:
+ obj = A(x=1, y=2)
+ sess.add(obj)
+ sess.commit()
+
+ with expect_deprecated(
+ "The InstanceState.unloaded_expirable attribute is deprecated. "
+ "Please use InstanceState.unloaded."
+ ):
+ eq_(inspect(obj).unloaded, {"id", "x", "y"})
+ eq_(inspect(obj).unloaded_expirable, inspect(obj).unloaded)
+
def test_evaluator_is_private(self):
with expect_deprecated(
"Direct use of 'EvaluatorCompiler' is not supported, and this "