title: SQLAlchemy query using contains, array casting and subqueries
body: <p>Any assistance turning the following query into a SQLAlchemy query would be greatly appreciated:</p>
  
  <pre><code>select * from app where (select app_ids from user where user_id=12345) @&gt; array[app_id];
  </code></pre>
  
  <ul>
  <li>app_id in app is an int column</li>
  <li>app_ids in user is an int[] column</li>
  <li>user_id in user is an int column</li>
  </ul>
  
  <p>I've tried a number of formulations, but all fail for one reason or another, here is an example that fails because ARRAY objects don't have a contained_by method:</p>
  
  <pre><code>subq = self.session.query(objects.User.app_ids).filter(objects.User.user_id == 12345).subquery('subq')
  
  self.session.query(objects.App).filter(postgresql.ARRAY(objects.App.app_id).contained_by(subq.c.app_ids)).all()
  </code></pre>
  
  <p>I've also tried the following equivalent raw queries without any luck.  Maybe these will be easier to translate though?  </p>
  
  <pre><code>select * from app where array[app_id] &lt;@ (select app_ids from user where user_id=12345);
  
  
  select * from app where app_id=ANY((select app_ids from user where user_id=12345)::integer[]);
  </code></pre>
  
  <p>All of these raw queries work fine in postgres. </p>
  
  <p>Thanks.</p>