Failed to autoconvert '1' to text.

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Failed to autoconvert '1' to text.
Date: 2013-09-06 08:13:43
Message-ID: CAFjNrYu1jvA0NkR8A+5ckxW0wLv_DP2oLnFk2qZjJfi1p92B8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2013-09-06 08:33:18 Re: Failed to autoconvert '1' to text.
Previous Message Boszormenyi Zoltan 2013-09-06 07:57:34 Re: Is this a bug in ECPG?