(cls)
| 141 | |
| 142 | @classmethod |
| 143 | def setup_mappers(cls): |
| 144 | parent, child, direction = cls.parent, cls.child, cls.direction |
| 145 | ta, tb, tc = cls.tables("a", "b", "c") |
| 146 | parent_table = {"a": ta, "b": tb, "c": tc}[parent] |
| 147 | child_table = {"a": ta, "b": tb, "c": tc}[child] |
| 148 | |
| 149 | remote_side = None |
| 150 | |
| 151 | if direction == MANYTOONE: |
| 152 | foreign_keys = [parent_table.c.child_id] |
| 153 | elif direction == ONETOMANY: |
| 154 | foreign_keys = [child_table.c.parent_id] |
| 155 | |
| 156 | atob = ta.c.id == tb.c.id |
| 157 | btoc = tc.c.id == tb.c.id |
| 158 | |
| 159 | if direction == ONETOMANY: |
| 160 | relationshipjoin = parent_table.c.id == child_table.c.parent_id |
| 161 | elif direction == MANYTOONE: |
| 162 | relationshipjoin = parent_table.c.child_id == child_table.c.id |
| 163 | if parent is child: |
| 164 | remote_side = [child_table.c.id] |
| 165 | |
| 166 | abcjoin = polymorphic_union( |
| 167 | { |
| 168 | "a": ta.select() |
| 169 | .where(tb.c.id == None) # noqa |
| 170 | .select_from(ta.outerjoin(tb, onclause=atob)) |
| 171 | .subquery(), |
| 172 | "b": ta.join(tb, onclause=atob) |
| 173 | .outerjoin(tc, onclause=btoc) |
| 174 | .select() |
| 175 | .where(tc.c.id == None) |
| 176 | .reduce_columns() |
| 177 | .subquery(), # noqa |
| 178 | "c": tc.join(tb, onclause=btoc).join(ta, onclause=atob), |
| 179 | }, |
| 180 | "type", |
| 181 | "abcjoin", |
| 182 | ) |
| 183 | |
| 184 | bcjoin = polymorphic_union( |
| 185 | { |
| 186 | "b": ta.join(tb, onclause=atob) |
| 187 | .outerjoin(tc, onclause=btoc) |
| 188 | .select() |
| 189 | .where(tc.c.id == None) |
| 190 | .reduce_columns() |
| 191 | .subquery(), # noqa |
| 192 | "c": tc.join(tb, onclause=btoc).join(ta, onclause=atob), |
| 193 | }, |
| 194 | "type", |
| 195 | "bcjoin", |
| 196 | ) |
| 197 | |
| 198 | class A(cls.Comparable): |
| 199 | def __init__(self, name): |
| 200 | self.a_data = name |
nothing calls this directly
no test coverage detected