Failed to autoconvert '1' to text. - Mailing list pgsql-general

From Szymon Guz
Subject Failed to autoconvert '1' to text.
Date
Msg-id CAFjNrYu1jvA0NkR8A+5ckxW0wLv_DP2oLnFk2qZjJfi1p92B8w@mail.gmail.com
Whole thread Raw
Responses Re: Failed to autoconvert '1' to text.  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Hi,
why isn't 'aa' always treated as string?

While testing function for levenshtein distance I've noticed that:

with x as (
  select 
  '1' a,
  '2' b
)
SELECT levenshtein(a, b), length(a)
FROM x;

ERROR:  failed to find conversion function from unknown to text

with x as (
  select 
  '1'::TEXT a,
  '2'::TEXT b
)
SELECT levenshtein(a, b), length(a)
FROM x;

 levenshtein | length 
-------------+--------
           1 |      1
(1 row)


Why should I cast '1' to '1'::TEXT to satisfy a function (TEXT, TEXT)?

thanks,
Szymon

pgsql-general by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: Is this a bug in ECPG?
Next
From: Richard Huxton
Date:
Subject: Re: Failed to autoconvert '1' to text.