title: Casting smallint to boolean in PostgreSQL
body: <p>I am trying to cast a smallint to a boolean in PostgreSQL. This does not work out of the box, for example:</p>
  
  <pre><code>select (1::smallint)::bool;
  </code></pre>
  
  <p>returns "ERROR: 42846: cannot cast type smallint to boolean"</p>
  
  <p>I can fix this using:</p>
  
  <pre><code>select (1::smallint)::int::bool;
  </code></pre>
  
  <p>but I'm wondering if there is a way I can define how to cast <code>smallint</code> directly to <code>boolean</code>?</p>
  
  <p>The reason for this is that I (and others that I work with) have summary queries which cast an <code>int</code> column from a database table to <code>boolean</code>. I would like to change this column to <code>smallint</code>, but doing so would brake this logic because there is no direct cast from <code>smallint</code> to <code>boolean</code>. Is it possible to use the postgres <code>CREATE CAST</code> to define how to cast a <code>smallint</code> to a <code>boolean</code>?</p>