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

Class MappedColumn

lib/sqlalchemy/orm/properties.py:511–934  ·  view source on GitHub ↗

Maps a single :class:`_schema.Column` on a class. :class:`_orm.MappedColumn` is a specialization of the :class:`_orm.ColumnProperty` class and is oriented towards declarative configuration. To construct :class:`_orm.MappedColumn` objects, use the :func:`_orm.mapped_column` cons

Source from the content-addressed store, hash-verified

509
510
511class MappedColumn(
512 _IntrospectsAnnotations,
513 _MapsColumns[_T],
514 _DeclarativeMapped[_T],
515):
516 """Maps a single :class:`_schema.Column` on a class.
517
518 :class:`_orm.MappedColumn` is a specialization of the
519 :class:`_orm.ColumnProperty` class and is oriented towards declarative
520 configuration.
521
522 To construct :class:`_orm.MappedColumn` objects, use the
523 :func:`_orm.mapped_column` constructor function.
524
525 .. versionadded:: 2.0
526
527
528 """
529
530 __slots__ = (
531 "column",
532 "_creation_order",
533 "_sort_order",
534 "foreign_keys",
535 "_has_nullable",
536 "_has_insert_default",
537 "deferred",
538 "deferred_group",
539 "deferred_raiseload",
540 "active_history",
541 "_attribute_options",
542 "_has_dataclass_arguments",
543 "_use_existing_column",
544 )
545
546 deferred: Union[_NoArg, bool]
547 deferred_raiseload: bool
548 deferred_group: Optional[str]
549
550 column: Column[_T]
551 foreign_keys: Optional[Set[ForeignKey]]
552 _attribute_options: _AttributeOptions
553
554 def __init__(self, *arg: Any, **kw: Any):
555 self._attribute_options = attr_opts = kw.pop(
556 "attribute_options", _DEFAULT_ATTRIBUTE_OPTIONS
557 )
558
559 self._use_existing_column = kw.pop("use_existing_column", False)
560
561 self._has_dataclass_arguments = (
562 attr_opts is not None
563 and attr_opts != _DEFAULT_ATTRIBUTE_OPTIONS
564 and any(
565 attr_opts[i] is not _NoArg.NO_ARG
566 for i, attr in enumerate(attr_opts._fields)
567 if attr != "dataclasses_default"
568 )

Callers 5

_setup_for_dataclassMethod · 0.85
_scan_attributesMethod · 0.85
mapped_columnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected