MCPcopy Create free account
hub / github.com/zzzeek/sqlalchemy / test_local_remote

Method test_local_remote

test/orm/test_relationships.py:3574–3606  ·  view source on GitHub ↗
(self, registry)

Source from the content-addressed store, hash-verified

3572 """test that local-remote is correctly determined for m2m"""
3573
3574 def test_local_remote(self, registry):
3575 meta = MetaData()
3576
3577 t1 = Table("t1", meta, Column("id", Integer, primary_key=True))
3578 t2 = Table("t2", meta, Column("id", Integer, primary_key=True))
3579 t12 = Table(
3580 "tab",
3581 meta,
3582 Column("t1_id", Integer, ForeignKey("t1.id")),
3583 Column("t2_id", Integer, ForeignKey("t2.id")),
3584 )
3585
3586 class A:
3587 pass
3588
3589 class B:
3590 pass
3591
3592 registry.map_imperatively(B, t2)
3593 m = registry.map_imperatively(
3594 A,
3595 t1,
3596 properties=dict(
3597 b_view=relationship(B, secondary=t12, viewonly=True),
3598 b_plain=relationship(B, secondary=t12),
3599 ),
3600 )
3601 configure_mappers()
3602 assert (
3603 m.get_property("b_view").local_remote_pairs
3604 == m.get_property("b_plain").local_remote_pairs
3605 == [(t1.c.id, t12.c.t1_id), (t2.c.id, t12.c.t2_id)]
3606 )
3607
3608
3609class ViewOnlyNonEquijoin(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 8

MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
ForeignKeyClass · 0.90
relationshipFunction · 0.90
configure_mappersFunction · 0.90
map_imperativelyMethod · 0.80
get_propertyMethod · 0.80

Tested by

no test coverage detected