MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_baked_mix

Method test_baked_mix

test/ext/test_horizontal_shard.py:569–592  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

567 )
568
569 def test_baked_mix(self):
570 sess = self._fixture_data()
571
572 tokyo = sess.query(WeatherLocation).filter_by(city="Tokyo").one()
573 tokyo.city
574 sess.expunge_all()
575
576 from sqlalchemy.ext.baked import BakedQuery
577
578 bakery = BakedQuery.bakery()
579
580 def get_tokyo(sess):
581 bq = bakery(lambda session: session.query(WeatherLocation))
582 t = bq(sess).get(tokyo.id)
583 return t
584
585 Sess = sessionmaker(class_=Session, bind=db2, autoflush=True)
586 sess2 = Sess()
587
588 t = get_tokyo(sess)
589 eq_(t.city, tokyo.city)
590
591 t = get_tokyo(sess2)
592 eq_(t.city, tokyo.city)
593
594 @testing.combinations(
595 "fetch", "evaluate", "auto", argnames="synchronize_session"

Callers

nothing calls this directly

Calls 8

_fixture_dataMethod · 0.95
sessionmakerClass · 0.90
eq_Function · 0.90
bakeryMethod · 0.80
oneMethod · 0.45
filter_byMethod · 0.45
queryMethod · 0.45
expunge_allMethod · 0.45

Tested by

no test coverage detected