MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_expand_dml_bulk

Method test_expand_dml_bulk

test/ext/test_hybrid.py:1805–1845  ·  view source on GitHub ↗
(self, crud, expand_dml, decl_base, connection)

Source from the content-addressed store, hash-verified

1803
1804 @testing.variation("crud", ["insert", "update"])
1805 def test_expand_dml_bulk(self, crud, expand_dml, decl_base, connection):
1806 A = expand_dml
1807 decl_base.metadata.create_all(connection)
1808
1809 with self.sql_execution_asserter(connection) as asserter:
1810 with Session(connection) as session:
1811 session.execute(
1812 insert(A),
1813 [
1814 {"id": 1, "xy": Point(3, 4)},
1815 {"id": 2, "xy": Point(5, 6)},
1816 ],
1817 )
1818
1819 if crud.update:
1820 session.execute(
1821 update(A),
1822 [
1823 {"id": 1, "xy": Point(10, 9)},
1824 {"id": 2, "xy": Point(7, 8)},
1825 ],
1826 )
1827 asserter.assert_(
1828 CompiledSQL(
1829 "INSERT INTO a (id, x, y) VALUES (:id, :x, :y)",
1830 [{"id": 1, "x": 3, "y": 4}, {"id": 2, "x": 5, "y": 6}],
1831 ),
1832 Conditional(
1833 crud.update,
1834 [
1835 CompiledSQL(
1836 "UPDATE a SET x=:x, y=:y WHERE a.id = :a_id",
1837 [
1838 {"x": 10, "y": 9, "a_id": 1},
1839 {"x": 7, "y": 8, "a_id": 2},
1840 ],
1841 )
1842 ],
1843 [],
1844 ),
1845 )
1846
1847 @testing.variation("keytype", ["attr", "string"])
1848 def test_expand_update_insert_values(self, expand_update, keytype):

Callers

nothing calls this directly

Calls 10

SessionClass · 0.90
insertFunction · 0.90
updateFunction · 0.90
CompiledSQLClass · 0.90
ConditionalClass · 0.90
create_allMethod · 0.80
PointClass · 0.70
executeMethod · 0.45
assert_Method · 0.45

Tested by

no test coverage detected