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

Method _make_prop_from_column

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

Source from the content-addressed store, hash-verified

2266 return prop
2267
2268 def _make_prop_from_column(
2269 self,
2270 key: str,
2271 column: Union[
2272 Sequence[KeyedColumnElement[Any]], KeyedColumnElement[Any]
2273 ],
2274 ) -> ColumnProperty[Any]:
2275 columns = util.to_list(column)
2276 mapped_column = []
2277 for c in columns:
2278 mc = self.persist_selectable.corresponding_column(c)
2279 if mc is None:
2280 mc = self.local_table.corresponding_column(c)
2281 if mc is not None:
2282 # if the column is in the local table but not the
2283 # mapped table, this corresponds to adding a
2284 # column after the fact to the local table.
2285 # [ticket:1523]
2286 self.persist_selectable._refresh_for_new_column(mc)
2287 mc = self.persist_selectable.corresponding_column(c)
2288 if mc is None:
2289 raise sa_exc.ArgumentError(
2290 "When configuring property '%s' on %s, "
2291 "column '%s' is not represented in the mapper's "
2292 "table. Use the `column_property()` function to "
2293 "force this column to be mapped as a read-only "
2294 "attribute." % (key, self, c)
2295 )
2296 mapped_column.append(mc)
2297 return properties.ColumnProperty(*mapped_column)
2298
2299 def _reconcile_prop_with_incoming_columns(
2300 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