MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _reflect_pk

Method _reflect_pk

lib/sqlalchemy/engine/reflection.py:1700–1725  ·  view source on GitHub ↗
(
        self,
        _reflect_info: _ReflectionInfo,
        table_key: TableKey,
        table: sa_schema.Table,
        cols_by_orig_name: Dict[str, sa_schema.Column[Any]],
        exclude_columns: Collection[str],
    )

Source from the content-addressed store, hash-verified

1698 table.append_column(col, replace_existing=True)
1699
1700 def _reflect_pk(
1701 self,
1702 _reflect_info: _ReflectionInfo,
1703 table_key: TableKey,
1704 table: sa_schema.Table,
1705 cols_by_orig_name: Dict[str, sa_schema.Column[Any]],
1706 exclude_columns: Collection[str],
1707 ) -> None:
1708 pk_cons = _reflect_info.pk_constraint.get(table_key)
1709 if pk_cons:
1710 pk_cols = [
1711 cols_by_orig_name[pk]
1712 for pk in pk_cons["constrained_columns"]
1713 if pk in cols_by_orig_name and pk not in exclude_columns
1714 ]
1715
1716 # update pk constraint name, comment and dialect_kwargs
1717 table.primary_key.name = pk_cons.get("name")
1718 table.primary_key.comment = pk_cons.get("comment", None)
1719 dialect_options = pk_cons.get("dialect_options")
1720 if dialect_options:
1721 table.primary_key.dialect_kwargs.update(dialect_options)
1722
1723 # tell the PKConstraint to re-initialize
1724 # its column collection
1725 table.primary_key._reload(pk_cols)
1726
1727 def _reflect_fk(
1728 self,

Callers 1

reflect_tableMethod · 0.95

Calls 3

_reloadMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected