title: sqlalchemy.exc.NoForeignKeysError: Could not determine join condition between parent/child tables
body: <p>I have several classes with the same relationship. For example:</p>
  
  <pre><code>class Foo(db.Model):
      __tablename__ = 'foo'
      foonr = Column('foonr', Integer, primary_key=True)
      bar= Column('bar_code',String, ForeignKey('bar.bar_code'))
      bar_rel = relationship('Foo', back_populates='foo_rel')
  
  class Bar(db.Model):
      __tablename__ = 'bar'
      code = Column('bar_code', String, primary_key=True)
      foo_rel = relationship('Foo', uselist=False, back_populates=' bar_rel')
  </code></pre>
  
  <p>This is almost a copy-paste from: <a href="http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html" rel="nofollow noreferrer">http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html</a>. However when I try to query an unrelated class (not Foo or Bar) in this example, I get following error:</p>
  
  <blockquote>
    <p>sqlalchemy.exc.NoForeignKeysError: Could not determine join condition
    between parent/child tables on relationship ... - there are no foreign
    keys linking these tables.  Ensure that referencing columns are
    associated with a ForeignKey or ForeignKeyConstraint, or specify a
    'primaryjoin' expression.</p>
  </blockquote>
  
  <p>Can someone explain this behaviour? Help me solve this problem?</p>
  
  <p>Thanks.</p>