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

Class TableGroupBlueprint

pydbml/parser/blueprints.py:304–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302
303@dataclass
304class TableGroupBlueprint(Blueprint):
305 name: str
306 items: List[str]
307 comment: Optional[str] = None
308 note: Optional[NoteBlueprint] = None
309 color: Optional[str] = None
310
311 def build(self) -> 'TableGroup':
312 if not self.parser:
313 raise RuntimeError('Parser is not set')
314 items = []
315 for table_name in self.items:
316 components = table_name.split('.')
317 schema, table = components if len(components) == 2 else ('public', components[0])
318 table_obj = self.parser.locate_table(schema, table)
319 if table_obj in items:
320 raise ValidationError(f'Table "{table}" is already in group "{self.name}"')
321 items.append(table_obj)
322 return TableGroup(
323 name=self.name,
324 items=items,
325 comment=self.comment,
326 note=self.note.build() if self.note else None,
327 color=self.color
328 )

Callers 4

test_buildMethod · 0.90
test_duplicate_tableMethod · 0.90
parse_table_groupFunction · 0.90

Calls

no outgoing calls

Tested by 3

test_buildMethod · 0.72
test_duplicate_tableMethod · 0.72