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

Method build

pydbml/parser/blueprints.py:211–243  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

209 properties: Optional[Dict[str, str]] = None
210
211 def build(self) -> 'Table':
212 result = Table(
213 name=self.name,
214 schema=self.schema,
215 alias=self.alias,
216 note=self.note.build() if self.note else None,
217 header_color=self.header_color,
218 comment=self.comment,
219 properties=self.properties
220 )
221 columns = self.columns or []
222 indexes = self.indexes or []
223 for col_bp in columns:
224 result.add_column(col_bp.build())
225 for index_bp in indexes:
226 index = index_bp.build()
227 new_subjects: List[Union[str, Column, Expression]] = []
228 for subj in index_bp.subject_names:
229 if isinstance(subj, ExpressionBlueprint):
230 new_subjects.append(subj.build())
231 else:
232 for col in result.columns:
233 if col.name == subj:
234 new_subjects.append(col)
235 break
236 else:
237 raise ColumnNotFoundError(
238 f'Cannot add index, column "{subj}" not defined in'
239 ' table "{self.name}".'
240 )
241 index.subjects = new_subjects
242 result.add_index(index)
243 return result
244
245 def get_reference_blueprints(self):
246 ''' the inline ones '''

Callers 6

test_build_minimalMethod · 0.95
test_with_columnsMethod · 0.95
test_with_indexesMethod · 0.95
test_bad_indexMethod · 0.95

Calls 5

add_columnMethod · 0.95
add_indexMethod · 0.95
TableClass · 0.90
ColumnNotFoundErrorClass · 0.90
buildMethod · 0.45

Tested by 6

test_build_minimalMethod · 0.76
test_with_columnsMethod · 0.76
test_with_indexesMethod · 0.76
test_bad_indexMethod · 0.76