MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_derived_dml_bulk

Method test_derived_dml_bulk

test/ext/test_hybrid.py:1929–1973  ·  view source on GitHub ↗
(self, crud, derived_dml, decl_base, connection)

Source from the content-addressed store, hash-verified

1927
1928 @testing.variation("crud", ["insert", "update"])
1929 def test_derived_dml_bulk(self, crud, derived_dml, decl_base, connection):
1930 A = derived_dml
1931 decl_base.metadata.create_all(connection)
1932
1933 with self.sql_execution_asserter(connection) as asserter:
1934 with Session(connection) as session:
1935 session.execute(
1936 insert(A),
1937 [
1938 {"rate": 1.5, "adjusted_amount": 25},
1939 {"rate": 2.5, "adjusted_amount": 25},
1940 ],
1941 )
1942
1943 if crud.update:
1944 session.execute(
1945 update(A),
1946 [
1947 {"id": 1, "rate": 1.8, "adjusted_amount": 30},
1948 {"id": 2, "rate": 2.8, "adjusted_amount": 40},
1949 ],
1950 )
1951 asserter.assert_(
1952 CompiledSQL(
1953 "INSERT INTO a (amount, rate) VALUES (:amount, :rate)",
1954 [
1955 {"amount": 25 / 1.5, "rate": 1.5},
1956 {"amount": 25 / 2.5, "rate": 2.5},
1957 ],
1958 ),
1959 Conditional(
1960 crud.update,
1961 [
1962 CompiledSQL(
1963 "UPDATE a SET amount=:amount, rate=:rate "
1964 "WHERE a.id = :a_id",
1965 [
1966 {"amount": 30 / 1.8, "rate": 1.8, "a_id": 1},
1967 {"amount": 40 / 2.8, "rate": 2.8, "a_id": 2},
1968 ],
1969 )
1970 ],
1971 [],
1972 ),
1973 )
1974
1975
1976class SpecialObjectTest(fixtures.TestBase, AssertsCompiledSQL):

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected