Re: problem with bytea and undecorated literals

Karsten Hilbert <[email protected]> Wed, 5 May 2010 12:46:09 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Tue, May 04, 2010 at 09:23:57AM +0100, Daniele Varrazzo wrote:

> There are always puffs of smoke coming out from my ears when I deal
> with timezones, so I'd like my other statement to be reviewed: it
> seems that if we cast a datetime with tz specified to ::timestamp we
> truncate the tz part:
> 
> test=> select '2010-05-04T02:27:11+08:00'::timestamp;
>       timestamp
> ---------------------
>  2010-05-04 02:27:11
> 
> so psycopg should decide which type to cast into according to the
> tzinfo presence:
> 
> test=> select '2010-05-04T02:27:11+08:00'::timestamptz;
>       timestamptz
> ------------------------
>  2010-05-03 19:27:11+01
> 
> ...even if this is not what I was expecting honestly... I should read
> PG docs about the argument again.
> 
> Is the behaviour "cast into timestamp if tzinfo is None, else
> timestamptz" a correct one for psycopg?

This seems correct to me unless the user has somehow
indicated otherwise - for example by providing her own
typecaster or by some (not currently existing) preference
flag or some such.

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