Issue #2981 wontfix

consider an interim relationship in immediate response to backref

Roman Alexeev
created an issue

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:

Tested on SQAlchemy 0.9.1, 0.9.2, 0.9.3.

Comments (5)

  1. Mike Bayer 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

    i'll leave this open in the meantime.

  2. Log in to comment