generate/update a :class:`.ColumnProperty` given a :class:`_schema.Column` or other SQL expression object.
(
self, key: str, column: KeyedColumnElement[Any], early_setup: bool
)
| 2364 | |
| 2365 | @util.preload_module("sqlalchemy.orm.descriptor_props") |
| 2366 | def _property_from_column( |
| 2367 | self, key: str, column: KeyedColumnElement[Any], early_setup: bool |
| 2368 | ) -> ColumnProperty[Any]: |
| 2369 | """generate/update a :class:`.ColumnProperty` given a |
| 2370 | :class:`_schema.Column` or other SQL expression object.""" |
| 2371 | |
| 2372 | descriptor_props = util.preloaded.orm_descriptor_props |
| 2373 | |
| 2374 | if early_setup: |
| 2375 | prop = None |
| 2376 | else: |
| 2377 | prop = self._props.get(key) |
| 2378 | |
| 2379 | if isinstance(prop, properties.ColumnProperty): |
| 2380 | return self._reconcile_prop_with_incoming_columns( |
| 2381 | key, |
| 2382 | prop, |
| 2383 | single_column=column, |
| 2384 | warn_only=prop.parent is not self, |
| 2385 | ) |
| 2386 | elif prop is None or isinstance( |
| 2387 | prop, descriptor_props.ConcreteInheritedProperty |
| 2388 | ): |
| 2389 | return self._make_prop_from_column(key, column) |
| 2390 | else: |
| 2391 | raise sa_exc.ArgumentError( |
| 2392 | "WARNING: when configuring property '%s' on %s, " |
| 2393 | "column '%s' conflicts with property '%r'. " |
| 2394 | "To resolve this, map the column to the class under a " |
| 2395 | "different name in the 'properties' dictionary. Or, " |
| 2396 | "to remove all awareness of the column entirely " |
| 2397 | "(including its availability as a foreign key), " |
| 2398 | "use the 'include_properties' or 'exclude_properties' " |
| 2399 | "mapper arguments to control specifically which table " |
| 2400 | "columns get mapped." % (key, self, column.key, prop) |
| 2401 | ) |
| 2402 | |
| 2403 | @util.langhelpers.tag_method_for_warnings( |
| 2404 | "This warning originated from the `configure_mappers()` process, " |
no test coverage detected