BUG #3661: Missing equality comparator: string = integer

Started by David Bachmannover 18 years ago3 messagesbugs
Jump to latest
#1David Bachmann
david.bachmann@ersystems.ch

The following bug has been logged online:

Bug reference: 3661
Logged by: David Bachmann
Email address: david.bachmann@ersystems.ch
PostgreSQL version: 8.3-beta1
Operating system: Windows XP
Description: Missing equality comparator: string = integer
Details:

This does not function any more under PG 8.3-beta1:

select '5'::varchar = 5;
ERROR: operator does not exist: character varying = integer

select '5'::char = 5;
ERROR: operator does not exist: character = integer

Note that this still works:
select '5' = 5;

#2Peter Eisentraut
peter_e@gmx.net
In reply to: David Bachmann (#1)
Re: BUG #3661: Missing equality comparator: string = integer

Am Dienstag, 9. Oktober 2007 schrieb David Bachmann:

This does not function any more under PG 8.3-beta1:

select '5'::varchar = 5;
ERROR: operator does not exist: character varying = integer

That is intentional. Fix your application by inserting appropriate explicit
casts.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: David Bachmann (#1)
Re: BUG #3661: Missing equality comparator: string = integer

This does not function any more under PG 8.3-beta1:

select '5'::varchar = 5;
ERROR: operator does not exist: character varying = integer

select '5'::char = 5;
ERROR: operator does not exist: character = integer

you cannot compare any character type and numeric type. If you wont to
do, you have to cast to text or use function to_char or to_numeric.

Note that this still works:
select '5' = 5;

It is integer = integer. Value in apostrophes doesn't mean 100% char
or varchar in Postgres. Pg detects unknown type (in apostrophes)
accordance with know type (integer)

try:
postgres=# select '5.0'=5;
ERROR: invalid input syntax for integer: "5a"

postgres=# select '5.0'=5;
ERROR: invalid input syntax for integer: "5.0"
postgres=# select '5.0'=5.0;
?column?
----------
t
(1 row)

Show quoted text

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq