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

Class Index

pydbml/_classes/index.py:16–80  ·  view source on GitHub ↗

Class representing index.

Source from the content-addressed store, hash-verified

14
15
16class Index(SQLObject, DBMLObject):
17 '''Class representing index.'''
18 required_attributes = ('subjects', 'table')
19 dont_compare_fields = ('table',)
20
21 def __init__(self,
22 subjects: List[Union[str, Column, Expression]],
23 name: Optional[str] = None,
24 unique: bool = False,
25 type: Optional[
26 Literal[
27 # https://www.postgresql.org/docs/current/indexes-types.html
28 "brin",
29 "btree",
30 "gin",
31 "gist",
32 "hash",
33 "spgist",
34 ]
35 ] = None,
36 pk: bool = False,
37 note: Optional[Union[Note, str]] = None,
38 comment: Optional[str] = None):
39 self.subjects = subjects
40 self.table: Optional[Table] = None
41
42 self.name = name if name else None
43 self.unique = unique
44 self.type = type
45 self.pk = pk
46 self.note = Note(note)
47 self.comment = comment
48
49 @property
50 def note(self):
51 return self._note
52
53 @note.setter
54 def note(self, val: Note) -> None:
55 self._note = val
56 val.parent = self
57
58 @property
59 def subject_names(self):
60 '''
61 Returns updated list of subject names.
62 '''
63 return [s.name if isinstance(s, Column) else str(s) for s in self.subjects]
64
65 def __repr__(self):
66 '''
67 <Index 'test', ['col', '(c*2)']>
68 ''&#x27;
69
70 table_name = self.table.name if self.table else None
71 return f"<Index {table_name!r}, {self.subject_names!r}>"
72
73 def __str__(self):

Callers 9

index1Function · 0.90
create_databaseMethod · 0.90
test_add_indexMethod · 0.90
test_delete_indexMethod · 0.90
test_okMethod · 0.90
test_note_propertyFunction · 0.90
buildMethod · 0.90

Calls

no outgoing calls

Tested by 8

index1Function · 0.72
create_databaseMethod · 0.72
test_add_indexMethod · 0.72
test_delete_indexMethod · 0.72
test_okMethod · 0.72
test_note_propertyFunction · 0.72