Thread: (No) Autocast in 8.4 with operators "=" and "LIKE"

(No) Autocast in 8.4 with operators "=" and "LIKE"

From
Daniel Schuchardt
Date:
Is that is the wished behavoir?<br /><br /><font color="#33cc00">template1=# SELECT 1='1';</font><br />  ?column?<br
/>----------<br />  t<br /> (1 row)<br /><br /><font color="#ff0000"><b>template1=# SELECT 1 LIKE '1';<br /> ERROR: 
operatordoes not exist: integer ~~ unknown at character 10</b></font><br /> HINT:  No operator matches the given name
andargument type(s). You might need to add explicit type casts.<br /> LINE 1: SELECT 1 LIKE '1';<br />                 
^<br/> template1=# SELECT version();<br />                            version<br />
-------------------------------------------------------------<br/>  PostgreSQL 8.4.0, compiled by Visual C++ build
1400,32-bit<br /> (1 row)<br /><br /><br /> thanks a lot.<br /><div class="moz-signature">-- <br /><p>Daniel
Schuchardt<br/><i><font size="2">Softwareentwicklung</font></i><p><font size="2"><a
href="http://www.prodat-sql.de">www.prodat-sql.de</a></font></div>

Re: (No) Autocast in 8.4 with operators "=" and "LIKE"

From
Alvaro Herrera
Date:
Daniel Schuchardt wrote:
> Is that is the wished behavoir?
>
> template1=# SELECT 1='1';
> ?column?
> ----------
> t
> (1 row)

Yes.  See also this:

alvherre=# select 1 = '1'::text;
ERROR:  operator does not exist: integer = text
LÍNEA 1: select 1 = '1'::text;                 ^
SUGERENCIA:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support