MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_pickle_load_only

Method test_pickle_load_only

test/orm/test_pickled.py:840–863  ·  view source on GitHub ↗

load_only() propagates a ``"column:*"`` token within InstanceState.load_options.

(self)

Source from the content-addressed store, hash-verified

838 eq_(PathRegistry.deserialize(path.serialize()).path, path.path)
839
840 def test_pickle_load_only(self):
841 """load_only() propagates a ``"column:*"`` token within
842 InstanceState.load_options."""
843
844 with fixture_session() as sess:
845 u1 = sess.scalars(select(User).options(load_only(User.name))).one()
846 sess.expunge_all()
847
848 # prior to the #13493 fix, in a fresh interpreter this raised
849 # KeyError: 'column:*'; see
850 # test_unpickle_other_process() for that condition
851 u2 = pickle.loads(pickle.dumps(u1))
852
853 eq_(
854 [
855 elem.path.path
856 for opt in u2._sa_instance_state.load_options
857 for elem in opt.context
858 ],
859 [
860 (inspect(User), inspect(User).attrs.name),
861 (inspect(User), PathToken._intern["column:*"]),
862 ],
863 )
864
865 def test_pickle_wildcard_raiseload(self):
866 """raiseload("*") leaves a _LoadLazyAttribute in

Callers

nothing calls this directly

Calls 11

fixture_sessionFunction · 0.90
selectFunction · 0.90
load_onlyFunction · 0.90
eq_Function · 0.90
inspectFunction · 0.90
oneMethod · 0.45
scalarsMethod · 0.45
optionsMethod · 0.45
expunge_allMethod · 0.45
loadsMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected