Thursday, February 17, 2011

How to find out if a lazy relation isn't loaded yet, with SQLAlchemy?

With SQLAlchemy, is there a way to know beforehand whether a relation would be lazy-loaded?
For example, given a lazy parent->children relation and an instance X of "parent", I'd like to know if "X.children" is already loaded, without triggering the query.

From stackoverflow
  • I think you could look at the child's __dict__ attribute dictionary to check if the data is already there or not.

    Joril : It works, thanks :)

0 comments:

Post a Comment