Re: problem with bytea and undecorated literals

Daniele Varrazzo <[email protected]> Tue, 4 May 2010 03:02:23 +0100
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Thu, Apr 29, 2010 at 9:54 AM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote:
> On 29/04/2010 10:33, Peter Eisentraut wrote:
> [snip]
>> For the bytea type, the following patch will fix both of these problems.
>> But again, this might affect other data types as well.
>
> You're right, this is a problem. We should probably go through all
> adapters and add explicit typecasts where necessary. Thank you.

I added the explicit cast on bytea and time-related objects: the
patches are in the python2 branch of my git repos.

I suggest not to pull yet the time part anyway: now a python datetime
is converted in postgres timestamp, but if a tz is specified it should
be converted in timestamptz instead. I wanted to do this, but I've
notice something that may be a bug in the timestamptz parsing:

>>> cur.execute("select '2010-05-04T02:27:11+08:00'::timestamptz")
>>> cur.fetchone()[0].isoformat()
'2010-05-03T19:27:11+01:00' # should have been 08:00

Tomorrow, or when I can, I'll try to debug the thing.

-- Daniele