generate/update a :class:`.ColumnProperty` given a :class:`_schema.Column` or other SQL expression object.
(
self, key: str, column: KeyedColumnElement[Any], early_setup: bool
)
| 2291 | |
| 2292 | @util.preload_module("sqlalchemy.orm.descriptor_props") |
| 2293 | def _property_from_column( |
| 2294 | self, key: str, column: KeyedColumnElement[Any], early_setup: bool |
| 2295 | ) -> ColumnProperty[Any]: |
| 2296 | """generate/update a :class:`.ColumnProperty` given a |
| 2297 | :class:`_schema.Column` or other SQL expression object.""" |
| 2298 | |
| 2299 | descriptor_props = util.preloaded.orm_descriptor_props |
| 2300 | |
| 2301 | if early_setup: |
| 2302 | prop = None |
| 2303 | else: |
| 2304 | prop = self._props.get(key) |
| 2305 | |
| 2306 | if isinstance(prop, properties.ColumnProperty): |
| 2307 | return self._reconcile_prop_with_incoming_columns( |
| 2308 | key, |
| 2309 | prop, |
| 2310 | single_column=column, |
| 2311 | warn_only=prop.parent is not self, |
| 2312 | ) |
| 2313 | elif prop is None or isinstance( |
| 2314 | prop, descriptor_props.ConcreteInheritedProperty |
| 2315 | ): |
| 2316 | return self._make_prop_from_column(key, column) |
| 2317 | else: |
| 2318 | raise sa_exc.ArgumentError( |
| 2319 | "WARNING: when configuring property '%s' on %s, " |
| 2320 | "column '%s' conflicts with property '%r'. " |
| 2321 | "To resolve this, map the column to the class under a " |
| 2322 | "different name in the 'properties' dictionary. Or, " |
| 2323 | "to remove all awareness of the column entirely " |
| 2324 | "(including its availability as a foreign key), " |
| 2325 | "use the 'include_properties' or 'exclude_properties' " |
| 2326 | "mapper arguments to control specifically which table " |
| 2327 | "columns get mapped." % (key, self, column.key, prop) |
| 2328 | ) |
| 2329 | |
| 2330 | @util.langhelpers.tag_method_for_warnings( |
| 2331 | "This warning originated from the `configure_mappers()` process, " |
no test coverage detected