Exemplo n.º 1
0
 def get_columns_by_constraint_types_table_name(
     self,
     table_name: str,
     constraint_types: Optional[Iterable[str]] = None,
 ) -> List['DBColumn']:
     """
     Get foreign columns by constraint types and table name
     """
     return list(
         filter(
             lambda c:
             (deep_getattr(c.constraint_table, 'name') == table_name and
              (set(c.constraint_type).intersection(set(constraint_types))
               if constraint_types else True)),
             self.columns.values(),
         ))
Exemplo n.º 2
0
 def is_self_fk(self):
     return (self.is_foreign_key and deep_getattr(
         self.constraint_table, 'name') == self.table_name)
Exemplo n.º 3
0
 def is_key_column(self):
     return (self.name in settings.KEY_COLUMN_NAMES or deep_getattr(
         self.constraint_table, 'name') == settings.KEY_TABLE_NAME  # noqa
             )