When Accessed Similarly, Why Does A Sqlalchemy Relationship Return Differently?
With this simplified model: class User(db.Model): id = db.Column(db.Integer, primary_key=True) # other attributes #user many-to-many size associations (using link tab
Solution 1:
SQLAlchemy uses metaclasses to construct models, which allows it to do all sorts of magic. When you declare the User class, it looks for attributes at the top level which are columns, relationships etc. and changes them to something different. You can check and find that isinstance(User.id, db.Column)
is false. But it doesn't pick up these objects inside something else like a dictionary.
Post a Comment for "When Accessed Similarly, Why Does A Sqlalchemy Relationship Return Differently?"