(self)
| 50 | |
| 51 | @property |
| 52 | def join_table(self) -> Optional[Table]: |
| 53 | if self.type != MANY_TO_MANY: |
| 54 | return None |
| 55 | |
| 56 | if self.table1 is None: |
| 57 | raise TableNotFoundError(f"Cannot generate join table for {self}: table 1 is unknown") |
| 58 | if self.table2 is None: |
| 59 | raise TableNotFoundError(f"Cannot generate join table for {self}: table 2 is unknown") |
| 60 | |
| 61 | return Table( |
| 62 | name=f'{self.table1.name}_{self.table2.name}', |
| 63 | schema=self.table1.schema, |
| 64 | columns=( |
| 65 | Column(name=f'{c.table.name}_{c.name}', type=c.type, not_null=True, pk=True) # type: ignore |
| 66 | for c in chain(self.col1, self.col2) |
| 67 | ), |
| 68 | abstract=True |
| 69 | ) |
| 70 | |
| 71 | @property |
| 72 | def table1(self) -> Optional[Table]: |
nothing calls this directly
no test coverage detected