(self)
| 1637 | } |
| 1638 | |
| 1639 | def _configure_properties(self) -> None: |
| 1640 | self._columns = sql_base.WriteableColumnCollection() |
| 1641 | |
| 1642 | # object attribute names mapped to MapperProperty objects |
| 1643 | self._props = util.OrderedDict() |
| 1644 | |
| 1645 | # table columns mapped to MapperProperty |
| 1646 | self._columntoproperty = _ColumnMapping(self) |
| 1647 | |
| 1648 | explicit_col_props_by_column: Dict[ |
| 1649 | KeyedColumnElement[Any], Tuple[str, ColumnProperty[Any]] |
| 1650 | ] = {} |
| 1651 | explicit_col_props_by_key: Dict[str, ColumnProperty[Any]] = {} |
| 1652 | |
| 1653 | # step 1: go through properties that were explicitly passed |
| 1654 | # in the properties dictionary. For Columns that are local, put them |
| 1655 | # aside in a separate collection we will reconcile with the Table |
| 1656 | # that's given. For other properties, set them up in _props now. |
| 1657 | if self._init_properties: |
| 1658 | for key, prop_arg in self._init_properties.items(): |
| 1659 | if not isinstance(prop_arg, MapperProperty): |
| 1660 | possible_col_prop = self._make_prop_from_column( |
| 1661 | key, prop_arg |
| 1662 | ) |
| 1663 | else: |
| 1664 | possible_col_prop = prop_arg |
| 1665 | |
| 1666 | # issue #8705. if the explicit property is actually a |
| 1667 | # Column that is local to the local Table, don't set it up |
| 1668 | # in ._props yet, integrate it into the order given within |
| 1669 | # the Table. |
| 1670 | |
| 1671 | _map_as_property_now = True |
| 1672 | if isinstance(possible_col_prop, properties.ColumnProperty): |
| 1673 | for given_col in possible_col_prop.columns: |
| 1674 | if self.local_table.c.contains_column(given_col): |
| 1675 | _map_as_property_now = False |
| 1676 | explicit_col_props_by_key[key] = possible_col_prop |
| 1677 | explicit_col_props_by_column[given_col] = ( |
| 1678 | key, |
| 1679 | possible_col_prop, |
| 1680 | ) |
| 1681 | |
| 1682 | if _map_as_property_now: |
| 1683 | self._configure_property( |
| 1684 | key, |
| 1685 | possible_col_prop, |
| 1686 | init=False, |
| 1687 | ) |
| 1688 | |
| 1689 | # step 2: pull properties from the inherited mapper. reconcile |
| 1690 | # columns with those which are explicit above. for properties that |
| 1691 | # are only in the inheriting mapper, set them up as local props |
| 1692 | if self.inherits: |
| 1693 | for key, inherited_prop in self.inherits._props.items(): |
| 1694 | if self._should_exclude(key, key, local=False, column=None): |
| 1695 | continue |
| 1696 |
no test coverage detected