MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_a_only

Method test_a_only

test/orm/inheritance/test_basic.py:1773–1810  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1771 )
1772
1773 def test_a_only(self):
1774 A, B, C = self.classes("A", "B", "C")
1775 self._fixture(a_p=True)
1776
1777 s = fixture_session()
1778 a1, b1, c1 = A(id=1), B(id=2), C(cid=1, id=3)
1779 s.add_all([a1, b1, c1])
1780 s.commit()
1781
1782 s.delete(a1)
1783
1784 with self.sql_execution_asserter(testing.db) as asserter:
1785 s.flush()
1786 asserter.assert_(
1787 CompiledSQL(
1788 "SELECT a.id, a.type FROM a WHERE a.id = :pk_1",
1789 [{"pk_1": 1}],
1790 ),
1791 CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 1}]),
1792 )
1793
1794 b1.id
1795 s.delete(b1)
1796 with self.sql_execution_asserter(testing.db) as asserter:
1797 s.flush()
1798 asserter.assert_(
1799 CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 2}])
1800 )
1801
1802 # want to see if the 'C' table loads even though
1803 # a and b are loaded
1804 c1 = s.query(A).filter_by(id=3).first()
1805 s.delete(c1)
1806 with self.sql_execution_asserter(testing.db) as asserter:
1807 s.flush()
1808 asserter.assert_(
1809 CompiledSQL("DELETE FROM a WHERE a.id = :id", [{"id": 3}])
1810 )
1811
1812
1813class OptimizedGetOnDeferredTest(fixtures.MappedTest):

Callers

nothing calls this directly

Calls 15

_fixtureMethod · 0.95
fixture_sessionFunction · 0.90
CompiledSQLClass · 0.90
AClass · 0.70
BClass · 0.70
CClass · 0.70
add_allMethod · 0.45
commitMethod · 0.45
deleteMethod · 0.45
flushMethod · 0.45
assert_Method · 0.45

Tested by

no test coverage detected