MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_named_with_column_objects

Method test_named_with_column_objects

test/sql/test_insert.py:1624–1674  ·  view source on GitHub ↗
(self, column_style)

Source from the content-addressed store, hash-verified

1622
1623 @testing.combinations(("strings",), ("columns",), ("inspectables",))
1624 def test_named_with_column_objects(self, column_style):
1625 table1 = self.tables.mytable
1626
1627 if column_style == "strings":
1628 myid, name, description = "myid", "name", "description"
1629
1630 elif column_style == "columns":
1631 myid, name, description = (
1632 table1.c.myid,
1633 table1.c.name,
1634 table1.c.description,
1635 )
1636 elif column_style == "inspectables":
1637 myid, name, description = (
1638 ORMExpr(table1.c.myid),
1639 ORMExpr(table1.c.name),
1640 ORMExpr(table1.c.description),
1641 )
1642 else:
1643 assert False
1644
1645 values = [
1646 {myid: 1, name: "a", description: "b"},
1647 {myid: 2, name: "c", description: "d"},
1648 {myid: 3, name: "e", description: "f"},
1649 ]
1650
1651 checkparams = {
1652 "myid_m0": 1,
1653 "myid_m1": 2,
1654 "myid_m2": 3,
1655 "name_m0": "a",
1656 "name_m1": "c",
1657 "name_m2": "e",
1658 "description_m0": "b",
1659 "description_m1": "d",
1660 "description_m2": "f",
1661 }
1662
1663 dialect = default.DefaultDialect()
1664 dialect.supports_multivalues_insert = True
1665
1666 self.assert_compile(
1667 table1.insert().values(values),
1668 "INSERT INTO mytable (myid, name, description) VALUES "
1669 "(:myid_m0, :name_m0, :description_m0), "
1670 "(:myid_m1, :name_m1, :description_m1), "
1671 "(:myid_m2, :name_m2, :description_m2)",
1672 checkparams=checkparams,
1673 dialect=dialect,
1674 )
1675
1676 def test_positional(self):
1677 table1 = self.tables.mytable

Callers

nothing calls this directly

Calls 4

ORMExprClass · 0.85
assert_compileMethod · 0.80
valuesMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected