Commits

Mike Bayer  committed be030dd

- Declarative will properly interpret the "foreign_keys" argument
on a backref() if it's a string.

  • Participants
  • Parent commits 06fc0cb

Comments (0)

Files changed (3)

       explicitly.  Allows mixins to be used with joined table
       inheritance.
 
+    - Declarative will properly interpret the "foreign_keys" argument
+      on a backref() if it's a string.
+      
 0.5.2
 ======
 

File lib/sqlalchemy/ext/declarative.py

                 setattr(prop, attr, resolve_arg(v))
 
         if prop.backref:
-            for attr in ('primaryjoin', 'secondaryjoin', 'secondary', '_foreign_keys', 'remote_side', 'order_by'):
+            for attr in ('primaryjoin', 'secondaryjoin', 'secondary', 'foreign_keys', 'remote_side', 'order_by'):
                if attr in prop.backref.kwargs and isinstance(prop.backref.kwargs[attr], basestring):
                    prop.backref.kwargs[attr] = resolve_arg(prop.backref.kwargs[attr])
 

File test/ext/declarative.py

             id = Column(Integer, primary_key=True)
             name = Column(String(50))
             addresses = relation("Address", order_by="desc(Address.email)", 
-                primaryjoin="User.id==Address.user_id", foreign_keys="[Address.user_id]")
+                primaryjoin="User.id==Address.user_id", foreign_keys="[Address.user_id]",
+                backref=backref('user', primaryjoin="User.id==Address.user_id", foreign_keys="[Address.user_id]")
+                )
         
         class Address(Base, ComparableEntity):
             __tablename__ = 'addresses'