Provides a surrogate :func:`_orm.mapped_column` that generates a so-called :term:`sentinel` column, allowing efficient bulk inserts with deterministic RETURNING sorting for tables that don't otherwise have qualifying primary key configurations. Use of :func:`_orm.orm_insert_sentinel
(
name: Optional[str] = None,
type_: Optional[_TypeEngineArgument[Any]] = None,
*,
default: Optional[Any] = None,
omit_from_statements: bool = True,
)
| 396 | |
| 397 | |
| 398 | def orm_insert_sentinel( |
| 399 | name: Optional[str] = None, |
| 400 | type_: Optional[_TypeEngineArgument[Any]] = None, |
| 401 | *, |
| 402 | default: Optional[Any] = None, |
| 403 | omit_from_statements: bool = True, |
| 404 | ) -> MappedColumn[Any]: |
| 405 | """Provides a surrogate :func:`_orm.mapped_column` that generates |
| 406 | a so-called :term:`sentinel` column, allowing efficient bulk |
| 407 | inserts with deterministic RETURNING sorting for tables that don't |
| 408 | otherwise have qualifying primary key configurations. |
| 409 | |
| 410 | Use of :func:`_orm.orm_insert_sentinel` is analogous to the use of the |
| 411 | :func:`_schema.insert_sentinel` construct within a Core |
| 412 | :class:`_schema.Table` construct. |
| 413 | |
| 414 | Guidelines for adding this construct to a Declarative mapped class |
| 415 | are the same as that of the :func:`_schema.insert_sentinel` construct; |
| 416 | the database table itself also needs to have a column with this name |
| 417 | present. |
| 418 | |
| 419 | For background on how this object is used, see the section |
| 420 | :ref:`engine_insertmanyvalues_sentinel_columns` as part of the |
| 421 | section :ref:`engine_insertmanyvalues`. |
| 422 | |
| 423 | .. seealso:: |
| 424 | |
| 425 | :func:`_schema.insert_sentinel` |
| 426 | |
| 427 | :ref:`engine_insertmanyvalues` |
| 428 | |
| 429 | :ref:`engine_insertmanyvalues_sentinel_columns` |
| 430 | |
| 431 | |
| 432 | .. versionadded:: 2.0.10 |
| 433 | |
| 434 | """ |
| 435 | |
| 436 | return mapped_column( |
| 437 | name=name, |
| 438 | default=( |
| 439 | default if default is not None else _InsertSentinelColumnDefault() |
| 440 | ), |
| 441 | _omit_from_statements=omit_from_statements, |
| 442 | insert_sentinel=True, |
| 443 | use_existing_column=True, |
| 444 | nullable=True, |
| 445 | ) |
| 446 | |
| 447 | |
| 448 | @util.deprecated_params( |
no test coverage detected