title: SQLAlchemy, update function add in other model
body: <p>I want to trigger Update function using SQLAlchemy, and I was able to get it working with using SQLAlchemy Text Function,</p>
  <p>With the following:</p>
  <pre><code>UPDATE device SET status='Unavailable' FROM center WHERE center.id = device.center_id AND center.is_connected=false RETURNING device.id 
  </code></pre>
  <p>However, I would like to make it as generic function, which I came up with something like this</p>
  <pre><code>
  from app.models import (
      Device,
      Center,
  )
  
  kwargs_filter = {}
  kwargs_filter[Center.id] = Device.center_id
  kwargs_filter[Center.is_connected] = False
  
  kwargs_update = {}
  kwargs_update[Device.status] = &quot;Unavailable&quot;
  </code></pre>
  <p>Then my db will trigger as:</p>
  <pre><code>await dbsession.execute(
      update(cls).
      where(kwargs_filter).
      values(kwargs_update).
      execution_options(synchronize_session=&quot;fetch&quot;)
  )
  await dbsession.commit()
  obj = await cls.get(dbsession, id=id)
  return obj
  </code></pre>
  <p>However, I am encountering error</p>
  <p>sqlalchemy.exc.ArgumentError: SQL expression for WHERE/HAVING role expected, got {&lt;sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x0000024A174FEB80&gt;: &lt;sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x0000024A1753A400&gt;, &lt;sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x0000024A17508400&gt;: False}.</p>