MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _reload

Method _reload

lib/sqlalchemy/sql/schema.py:5405–5432  ·  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

5403 self._columns.extend(table_pks)
5404
5405 def _reload(self, columns: Iterable[Column[Any]]) -> None:
5406 """repopulate this :class:`.PrimaryKeyConstraint` given
5407 a set of columns.
5408
5409 Existing columns in the table that are marked as primary_key=True
5410 are maintained.
5411
5412 Also fires a new event.
5413
5414 This is basically like putting a whole new
5415 :class:`.PrimaryKeyConstraint` object on the parent
5416 :class:`_schema.Table` object without actually replacing the object.
5417
5418 The ordering of the given list of columns is also maintained; these
5419 columns will be appended to the list of columns after any which
5420 are already present.
5421
5422 """
5423 # set the primary key flag on new columns.
5424 # note any existing PK cols on the table also have their
5425 # flag still set.
5426 for col in columns:
5427 col.primary_key = True
5428
5429 self._columns.extend(columns)
5430
5431 PrimaryKeyConstraint._autoincrement_column._reset(self) # type: ignore
5432 self._set_parent_with_dispatch(self.table)
5433
5434 def _replace(self, col: Column[Any]) -> None:
5435 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