Fix adding property to mapper before mapping is complete
Fixed issue where calling :meth:`.Mapper.add_property` within mapper event
hooks such as :meth:`.MapperEvents.instrument_class`,
:meth:`.MapperEvents.after_mapper_constructed`, or
:meth:`.MapperEvents.before_mapper_configured` would raise an
``AttributeError`` because the mapper's internal property collections were
not yet initialized. The :meth:`.Mapper.add_property` method now handles
early-stage property additions correctly, allowing properties including
column properties, deferred columns, and relationships to be added during
mapper initialization events. Pull request courtesy G Allajmi.
Fixes: #12858
Closes: #13023
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13023
Pull-request-sha:
fa9a0ae4bb07819307e6c9d6ec5fd4c9706bf67e
Change-Id: Ibb794c401102a8d23d157b40353f272d5735b49a