r"""Indicate a column-based mapped attribute that by default will not load unless accessed. When using :func:`_orm.mapped_column`, the same functionality as that of :func:`_orm.deferred` construct is provided by using the :paramref:`_orm.mapped_column.deferred` parameter. :para
(
column: _ORMColumnExprArgument[_T],
*additional_columns: _ORMColumnExprArgument[Any],
group: Optional[str] = None,
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,
)
| 2190 | |
| 2191 | |
| 2192 | def deferred( |
| 2193 | column: _ORMColumnExprArgument[_T], |
| 2194 | *additional_columns: _ORMColumnExprArgument[Any], |
| 2195 | group: Optional[str] = None, |
| 2196 | raiseload: bool = False, |
| 2197 | comparator_factory: Optional[Type[PropComparator[_T]]] = None, |
| 2198 | init: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 2199 | repr: Union[_NoArg, bool] = _NoArg.NO_ARG, # noqa: A002 |
| 2200 | default: Optional[Any] = _NoArg.NO_ARG, |
| 2201 | default_factory: Union[_NoArg, Callable[[], _T]] = _NoArg.NO_ARG, |
| 2202 | compare: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 2203 | kw_only: Union[_NoArg, bool] = _NoArg.NO_ARG, |
| 2204 | hash: Union[_NoArg, bool, None] = _NoArg.NO_ARG, # noqa: A002 |
| 2205 | active_history: bool = False, |
| 2206 | expire_on_flush: bool = True, |
| 2207 | info: Optional[_InfoType] = None, |
| 2208 | doc: Optional[str] = None, |
| 2209 | dataclass_metadata: Union[_NoArg, Mapping[Any, Any], None] = _NoArg.NO_ARG, |
| 2210 | ) -> MappedSQLExpression[_T]: |
| 2211 | r"""Indicate a column-based mapped attribute that by default will |
| 2212 | not load unless accessed. |
| 2213 | |
| 2214 | When using :func:`_orm.mapped_column`, the same functionality as |
| 2215 | that of :func:`_orm.deferred` construct is provided by using the |
| 2216 | :paramref:`_orm.mapped_column.deferred` parameter. |
| 2217 | |
| 2218 | :param \*columns: columns to be mapped. This is typically a single |
| 2219 | :class:`_schema.Column` object, |
| 2220 | however a collection is supported in order |
| 2221 | to support multiple columns mapped under the same attribute. |
| 2222 | |
| 2223 | :param raiseload: boolean, if True, indicates an exception should be raised |
| 2224 | if the load operation is to take place. |
| 2225 | |
| 2226 | .. versionadded:: 1.4 |
| 2227 | |
| 2228 | |
| 2229 | Additional arguments are the same as that of :func:`_orm.column_property`. |
| 2230 | |
| 2231 | .. seealso:: |
| 2232 | |
| 2233 | :ref:`orm_queryguide_deferred_imperative` |
| 2234 | |
| 2235 | """ |
| 2236 | return MappedSQLExpression( |
| 2237 | column, |
| 2238 | *additional_columns, |
| 2239 | attribute_options=_AttributeOptions( |
| 2240 | init, |
| 2241 | repr, |
| 2242 | default, |
| 2243 | default_factory, |
| 2244 | compare, |
| 2245 | kw_only, |
| 2246 | hash, |
| 2247 | dataclass_metadata, |
| 2248 | ), |
| 2249 | group=group, |