title: PGError: ERROR: operator does not exist: boolean ~~* unknown
body: <p>Locally I’m developing with SQLite, but on my production host I’m running PostgreSQL. Locally everything’s fine but not so on the production host.</p>
  
  <p>I have built kind of a search form with which I can evaluate all data in my database with any combination I’d like. This seems to work fine as long as I don’t use boolean and/or date fields. PostgreSQL doesn’t seem to like my code very much…</p>
  
  <p>So, here’s some example code:</p>
  
  <pre><code>unless params[:analysis][:sporty].blank?
    tmp_conditions_customer &lt;&lt; ["(sporty ILIKE ?)", "%#{params[:analysis][:sporty]}%"]
  end
  </code></pre>
  
  <p>This evaluates to</p>
  
  <pre><code>SELECT COUNT(*) FROM "customers" WHERE ((sporty ILIKE '%%') 
  </code></pre>
  
  <p>Why’s that anyway? Why the '%%'?</p>
  
  <p>For testing the deployment I’m using Heroku with the Exceptional plugin. This plugin gives me the following hint:</p>
  
  <p><code>HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.</code></p>
  
  <p>Thanks Exceptional, but what the heck does that mean? :-D Type casts for SQL queries? How’s that gonna work?</p>
  
  <p>In my migration the database field looks like this:</p>
  
  <pre><code>t.boolean :sporty
  </code></pre>
  
  <p>And in the form where I’m creating this data I’m using this code</p>
  
  <pre><code>&lt;%= f.label :sporty %&gt;&lt;br /&gt;
  &lt;%= f.select :sporty, options_for_select({ "Ja"  =&gt; true, "Nein" =&gt; false }), { :include_blank =&gt; '-----'}  %&gt;
  </code></pre>
  
  <p>As I already mentioned, SQLite is my friend, seems to be the much stricter evaluation of PostgreSQL which causes the trouble.</p>
  
  <p>Thanks for your help in advance.</p>