r"""Provide a column-level property for use with a mapping. With Declarative mappings, :func:`_orm.column_property` is used to map read-only SQL expressions to a mapped class. When using Imperative mappings, :func:`_orm.column_property` also takes on the role of mapping table colum
(
column: _ORMColumnExprArgument[_T],
*additional_columns: _ORMColumnExprArgument[Any],
group: Optional[str] = None,
deferred: bool = False,
raiseload: bool = False,
comparator_factory: Optional[Type[PropComparator[_T]]] = None,
init: Union[_NoArg, bool] = _NoArg.NO_ARG,
repr: Union[_NoArg, bool] = _NoArg.NO_ARG, # noqa: A002
default: Optional[Any] = _NoArg.NO_ARG,
default_factory: Union[_NoArg, Callable[[], _T]] = _NoArg.NO_ARG,
compare: Union[_NoArg, bool] = _NoArg.NO_ARG,
kw_only: Union[_NoArg, bool] = _NoArg.NO_ARG,
hash: Union[_NoArg, bool, None] = _NoArg.NO_ARG, # noqa: A002
active_history: bool = False,
expire_on_flush: bool = True,
info: Optional[_InfoType] = None,
doc: Optional[str] = None,
dataclass_metadata: Union[_NoArg, Mapping[Any, Any], None] = _NoArg.NO_ARG,
)
| 459 | } |
| 460 | ) |
| 461 | def column_property( |
| 462 | column: _ORMColumnExprArgument[_T], |
| 463 | *additional_columns: _ORMColumnExprArgument[Any], |
| 464 | group: Optional[str] = None, |
| 465 | deferred: bool = False, |
| 466 | raiseload: bool = False, |
| 467 | comparator_factory: Optional[Type[PropComparator[_T]]] = None, |
| 468 | init: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 469 | repr: Union[_NoArg, bool] = _NoArg.NO_ARG, # noqa: A002 |
| 470 | default: Optional[Any] = _NoArg.NO_ARG, |
| 471 | default_factory: Union[_NoArg, Callable[[], _T]] = _NoArg.NO_ARG, |
| 472 | compare: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 473 | kw_only: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 474 | hash: Union[_NoArg, bool, None] = _NoArg.NO_ARG, # noqa: A002 |
| 475 | active_history: bool = False, |
| 476 | expire_on_flush: bool = True, |
| 477 | info: Optional[_InfoType] = None, |
| 478 | doc: Optional[str] = None, |
| 479 | dataclass_metadata: Union[_NoArg, Mapping[Any, Any], None] = _NoArg.NO_ARG, |
| 480 | ) -> MappedSQLExpression[_T]: |
| 481 | r"""Provide a column-level property for use with a mapping. |
| 482 | |
| 483 | With Declarative mappings, :func:`_orm.column_property` is used to |
| 484 | map read-only SQL expressions to a mapped class. |
| 485 | |
| 486 | When using Imperative mappings, :func:`_orm.column_property` also |
| 487 | takes on the role of mapping table columns with additional features. |
| 488 | When using fully Declarative mappings, the :func:`_orm.mapped_column` |
| 489 | construct should be used for this purpose. |
| 490 | |
| 491 | With Declarative Dataclass mappings, :func:`_orm.column_property` |
| 492 | is considered to be **read only**, and will not be included in the |
| 493 | Dataclass ``__init__()`` constructor. |
| 494 | |
| 495 | The :func:`_orm.column_property` function returns an instance of |
| 496 | :class:`.ColumnProperty`. |
| 497 | |
| 498 | .. seealso:: |
| 499 | |
| 500 | :ref:`mapper_column_property_sql_expressions` - general use of |
| 501 | :func:`_orm.column_property` to map SQL expressions |
| 502 | |
| 503 | :ref:`orm_imperative_table_column_options` - usage of |
| 504 | :func:`_orm.column_property` with Imperative Table mappings to apply |
| 505 | additional options to a plain :class:`_schema.Column` object |
| 506 | |
| 507 | :param \*cols: |
| 508 | list of Column objects to be mapped. |
| 509 | |
| 510 | :param active_history=False: |
| 511 | |
| 512 | Used only for Imperative Table mappings, or legacy-style Declarative |
| 513 | mappings (i.e. which have not been upgraded to |
| 514 | :func:`_orm.mapped_column`), for column-based attributes that are |
| 515 | expected to be writeable; use :func:`_orm.mapped_column` with |
| 516 | :paramref:`_orm.mapped_column.active_history` for Declarative mappings. |
| 517 | See that parameter for functional details. |
| 518 |