MCPcopy Create free account
hub / github.com/Vanderhoof/PyDBML / join_table

Method join_table

pydbml/_classes/reference.py:52–69  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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]:

Callers

nothing calls this directly

Calls 3

TableNotFoundErrorClass · 0.90
TableClass · 0.85
ColumnClass · 0.85

Tested by

no test coverage detected