How to use ilike sqlalchemy on postgresql array field?
<p>I'm trying to match some names with the names I already have in my Postgresql database, using the following code:</p>

<pre><code>last_like = '{last_name}%'.format(last_name)
matches = Session.query(MyTable).filter(or_(
    MyTable.name.ilike(last_like),
    MyTable.other_names.any(last_like, operator=ilike_op),
)).all()
</code></pre>

<p>Essentially it tries to match the name column <em>or</em> any of the other names stored as an array in the other_names column.</p>

<p>But I get:</p>

<pre><code>KeyError: &lt;function ilike_op at 0x7fb5269e2500&gt;
</code></pre>

<p>What am I doing wrong?</p>