MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_with_polymorphic

Method test_with_polymorphic

test/orm/test_compile.py:24–118  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

22 clear_mappers()
23
24 def test_with_polymorphic(self):
25 metadata = MetaData()
26
27 order = Table(
28 "orders",
29 metadata,
30 Column("id", Integer, primary_key=True),
31 Column(
32 "employee_id",
33 Integer,
34 ForeignKey("employees.id"),
35 nullable=False,
36 ),
37 Column("type", Unicode(16)),
38 )
39
40 employee = Table(
41 "employees",
42 metadata,
43 Column("id", Integer, primary_key=True),
44 Column("name", Unicode(16), unique=True, nullable=False),
45 )
46
47 product = Table(
48 "products", metadata, Column("id", Integer, primary_key=True)
49 )
50
51 orderproduct = Table(
52 "orderproducts",
53 metadata,
54 Column("id", Integer, primary_key=True),
55 Column(
56 "order_id", Integer, ForeignKey("orders.id"), nullable=False
57 ),
58 Column(
59 "product_id",
60 Integer,
61 ForeignKey("products.id"),
62 nullable=False,
63 ),
64 )
65
66 class Order:
67 pass
68
69 class Employee:
70 pass
71
72 class Product:
73 pass
74
75 class OrderProduct:
76 pass
77
78 order_join = order.select().alias("pjoin")
79
80 self.mapper_registry.map_imperatively(
81 Order,

Callers

nothing calls this directly

Calls 10

MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
ForeignKeyClass · 0.90
UnicodeClass · 0.90
relationshipFunction · 0.90
configure_mappersFunction · 0.90
map_imperativelyMethod · 0.80
aliasMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected