- edited description
consider an interim relationship in immediate response to backref
I seems that relationship declared as a backref does not load until you do something with a model for the first time (just requesting a list of relationship is enough).
Here is a gist showcasing the problem: https://gist.github.com/letit-bee/9323748
Tested on SQAlchemy 0.9.1, 0.9.2, 0.9.3.
Comments (5)
-
reporter -
repo owner This is a well known issue, which is because backref() does not immediately attach anything to the host class (it can't, the class might not have been declared yet). It would require some complex scheme such that the new relationship is associated with the remote class as soon as that class is mapped, however the overall configure process hasn't happened yet which is currently used to make determinations about how the backref will be built, so that process would have to be split up somehow.
The usual workaround is to just make sure mappers are configured:
from sqlalchemy.orm import configure_mappers configure_mappers()
i'll leave this open in the meantime.
-
repo owner - marked as major
- changed title to consider an interim relationship in immediate response to backref
- changed component to orm
- changed milestone to 0.9.xx
-
repo owner - changed milestone to 1.0.xx
-
repo owner - changed status to wontfix
the approach is to continue encouraging users to use back_populates instead of backref.
- Log in to comment