MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _make_prop_from_column

Method _make_prop_from_column

lib/sqlalchemy/orm/mapper.py:2196–2225  ·  view source on GitHub ↗
(
        self,
        key: str,
        column: Union[
            Sequence[KeyedColumnElement[Any]], KeyedColumnElement[Any]
        ],
    )

Source from the content-addressed store, hash-verified

2194 return prop
2195
2196 def _make_prop_from_column(
2197 self,
2198 key: str,
2199 column: Union[
2200 Sequence[KeyedColumnElement[Any]], KeyedColumnElement[Any]
2201 ],
2202 ) -> ColumnProperty[Any]:
2203 columns = util.to_list(column)
2204 mapped_column = []
2205 for c in columns:
2206 mc = self.persist_selectable.corresponding_column(c)
2207 if mc is None:
2208 mc = self.local_table.corresponding_column(c)
2209 if mc is not None:
2210 # if the column is in the local table but not the
2211 # mapped table, this corresponds to adding a
2212 # column after the fact to the local table.
2213 # [ticket:1523]
2214 self.persist_selectable._refresh_for_new_column(mc)
2215 mc = self.persist_selectable.corresponding_column(c)
2216 if mc is None:
2217 raise sa_exc.ArgumentError(
2218 "When configuring property '%s' on %s, "
2219 "column '%s' is not represented in the mapper's "
2220 "table. Use the `column_property()` function to "
2221 "force this column to be mapped as a read-only "
2222 "attribute." % (key, self, c)
2223 )
2224 mapped_column.append(mc)
2225 return properties.ColumnProperty(*mapped_column)
2226
2227 def _reconcile_prop_with_incoming_columns(
2228 self,

Callers 2

_configure_propertiesMethod · 0.95
_property_from_columnMethod · 0.95

Calls 3

corresponding_columnMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected