Re: problem with bytea and undecorated literals

Karsten Hilbert <[email protected]> Thu, 29 Apr 2010 12:32:32 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Thu, Apr 29, 2010 at 11:09:54AM +0100, Daniele Varrazzo wrote:

> This is actually a shortcoming in the PostgreSQL casting algorithm, as
> the same problem would appear issuing the query directly in psql:
> 
> test=> SELECT foo (ARRAY[E'abc\\\\000S', E'def']);
> ERROR:  function foo(text[]) does not exist
> LINE 1: SELECT foo (ARRAY[E'abc\\\\000S', E'def']);
>                ^
> HINT:  No function matches the given name and argument types. You
> might need to add explicit type casts.
> test=> SELECT foo (ARRAY[E'abc\\\\000S', E'def']::bytea[]);
>  foo
> -----
>  123
> (1 row)

I'm not sure I agree it's the same problem. Psql (and by
extension PostgreSQL) does NOT know the "intended" datatype
(and choses to not second guess) whereas psycopg2 DOES
(that's what it is proud of - mapping Python data types to
PG ones and back).

Or am I missing something ?

Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346