0c6ff08 db models: replace backref= with back_populates=

Authored and Committed by kparal 2 years ago
    db models: replace backref= with back_populates=
    
    The advantage of `back_populates=` is that it is defined on both sides of the
    relationship. Therefore when you look at a class, it is clear which attributes
    it has, no attributes are created silently by a completely different class/
    module. You can also define additional parameters like `lazy` and `order_by`
    on the correct side of the relationship, rather than have it reversed.
    
    The downside of defining the relationship on both sides is that it's much easier
    to stumble into a circular import. I had to rework the imports to only import
    a module (instead of a particular class), and all typehints had to be defined
    as strings. The association tables had to be moved into an independent module
    (I decided to use `__init__.py`).
    
        
  • Zuul
    success
    Jobs result is success
    2 years ago
file modified
+13 -8
file modified
+15 -11
file modified
+16 -36