MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / MappedColumn

Class MappedColumn

lib/sqlalchemy/orm/properties.py:516–972  ·  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

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

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