test that conflicting backrefs raises an exception
(self)
| 118 | configure_mappers() |
| 119 | |
| 120 | def test_conflicting_backref_one(self): |
| 121 | """test that conflicting backrefs raises an exception""" |
| 122 | |
| 123 | metadata = MetaData() |
| 124 | |
| 125 | order = Table( |
| 126 | "orders", |
| 127 | metadata, |
| 128 | Column("id", Integer, primary_key=True), |
| 129 | Column("type", Unicode(16)), |
| 130 | ) |
| 131 | |
| 132 | product = Table( |
| 133 | "products", metadata, Column("id", Integer, primary_key=True) |
| 134 | ) |
| 135 | |
| 136 | orderproduct = Table( |
| 137 | "orderproducts", |
| 138 | metadata, |
| 139 | Column("id", Integer, primary_key=True), |
| 140 | Column( |
| 141 | "order_id", Integer, ForeignKey("orders.id"), nullable=False |
| 142 | ), |
| 143 | Column( |
| 144 | "product_id", |
| 145 | Integer, |
| 146 | ForeignKey("products.id"), |
| 147 | nullable=False, |
| 148 | ), |
| 149 | ) |
| 150 | |
| 151 | class Order: |
| 152 | pass |
| 153 | |
| 154 | class Product: |
| 155 | pass |
| 156 | |
| 157 | class OrderProduct: |
| 158 | pass |
| 159 | |
| 160 | order_join = order.select().alias("pjoin") |
| 161 | |
| 162 | self.mapper_registry.map_imperatively( |
| 163 | Order, |
| 164 | order, |
| 165 | with_polymorphic=("*", order_join), |
| 166 | polymorphic_on=order_join.c.type, |
| 167 | polymorphic_identity="order", |
| 168 | properties={ |
| 169 | "orderproducts": relationship( |
| 170 | OrderProduct, lazy="select", backref="product" |
| 171 | ) |
| 172 | }, |
| 173 | ) |
| 174 | |
| 175 | self.mapper_registry.map_imperatively( |
| 176 | Product, |
| 177 | product, |
nothing calls this directly
no test coverage detected