MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_synonym_fk

Method test_synonym_fk

test/orm/test_relationships.py:1543–1580  ·  view source on GitHub ↗

test that active history is enabled on a one-to-many/one that has use_get==True

(self)

Source from the content-addressed store, hash-verified

1541 return self._a_id
1542
1543 def test_synonym_fk(self):
1544 """test that active history is enabled on a
1545 one-to-many/one that has use_get==True"""
1546
1547 tableB, A, B, tableA = (
1548 self.tables.tableB,
1549 self.classes.A,
1550 self.classes.B,
1551 self.tables.tableA,
1552 )
1553
1554 self.mapper_registry.map_imperatively(
1555 B, tableB, properties={"a_id": synonym("_a_id", map_column=True)}
1556 )
1557 self.mapper_registry.map_imperatively(
1558 A,
1559 tableA,
1560 properties={
1561 "b": relationship(
1562 B,
1563 primaryjoin=(tableA.c.id == foreign(B.a_id)),
1564 uselist=False,
1565 )
1566 },
1567 )
1568
1569 sess = fixture_session()
1570
1571 b = B(id=0)
1572 a = A(id=0, b=b)
1573 sess.add(a)
1574 sess.add(b)
1575 sess.flush()
1576 sess.expunge_all()
1577
1578 assert a.b == b
1579 assert a.id == b.a_id
1580 assert a.id == b._a_id
1581
1582
1583class FKsAsPksTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 10

synonymFunction · 0.90
relationshipFunction · 0.90
foreignFunction · 0.90
fixture_sessionFunction · 0.90
map_imperativelyMethod · 0.80
BClass · 0.70
AClass · 0.70
addMethod · 0.45
flushMethod · 0.45
expunge_allMethod · 0.45

Tested by

no test coverage detected