MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _reload

Method _reload

lib/sqlalchemy/sql/schema.py:5022–5049  ·  view source on GitHub ↗

repopulate this :class:`.PrimaryKeyConstraint` given a set of columns. Existing columns in the table that are marked as primary_key=True are maintained. Also fires a new event. This is basically like putting a whole new :class:`.PrimaryKeyConstraint

(self, columns: Iterable[Column[Any]])

Source from the content-addressed store, hash-verified

5020 self._columns.extend(table_pks)
5021
5022 def _reload(self, columns: Iterable[Column[Any]]) -> None:
5023 """repopulate this :class:`.PrimaryKeyConstraint` given
5024 a set of columns.
5025
5026 Existing columns in the table that are marked as primary_key=True
5027 are maintained.
5028
5029 Also fires a new event.
5030
5031 This is basically like putting a whole new
5032 :class:`.PrimaryKeyConstraint` object on the parent
5033 :class:`_schema.Table` object without actually replacing the object.
5034
5035 The ordering of the given list of columns is also maintained; these
5036 columns will be appended to the list of columns after any which
5037 are already present.
5038
5039 """
5040 # set the primary key flag on new columns.
5041 # note any existing PK cols on the table also have their
5042 # flag still set.
5043 for col in columns:
5044 col.primary_key = True
5045
5046 self._columns.extend(columns)
5047
5048 PrimaryKeyConstraint._autoincrement_column._reset(self) # type: ignore
5049 self._set_parent_with_dispatch(self.table)
5050
5051 def _replace(self, col: Column[Any]) -> None:
5052 PrimaryKeyConstraint._autoincrement_column._reset(self) # type: ignore

Callers 1

_reflect_pkMethod · 0.80

Calls 3

extendMethod · 0.45
_resetMethod · 0.45

Tested by

no test coverage detected