title: Flask SQL-Alchemy | MySql - Multiple Foreign Keys issues
body: <pre><code>class Role(db.Model):
      __tablename__ = 'roles'
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(64), unique=True)
      default = db.Column(db.Boolean, default=False, index=True)
      permissions = db.Column(db.Integer)
  
  
  class Devices(db.Model):
      __tablename__ = 'devices'
      id = db.Column(db.Integer, primary_key=True)
      purpose = db.Column('purpose', db.String(64))
      type = db.Column('type', db.String(64))
      name = db.Column('name', db.String(64))
      channel = db.Column('channel', db.Integer)
      role_id = db.Column('role_id', db.Integer)
      role_permissions = db.Column('role_permissions', db.Integer)
      role = db.ForeignKeyConstraint(['role_id', 'role_permissions'], ['roles.id', 'roles.permissions'])
  </code></pre>
  
  <p>Then I would expect this to work:</p>
  
  <pre><code>dev = Devices(purpose="lights",type="tcp",name="zeus",channel=8)
  role = Role.query.first()
  dev.role = role
  db.session.add(dev)
  db.session.commit()
  </code></pre>
  
  <p>But once persisted, role_id and role_permissions get null value. Why? Whats the right way to do this??</p>