Skip site navigation (1) Skip section navigation (2)

Re: Change in datetime type casting

From: Federico Di Gregorio <fog(at)dndg(dot)it>
To: psycopg(at)postgresql(dot)org
Subject: Re: Change in datetime type casting
Date: 2012-06-28 06:30:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: psycopg
On 28/06/12 01:19, Adrian Klaver wrote:
> From the docs:
>>>> dt =
>>>> dt
> datetime.datetime(2010, 2, 8, 1, 40, 27, 425337)
>>>> cur.mogrify("SELECT %s, %s, %s;", (dt,, dt.time()))
> "SELECT '2010-02-08T01:40:27.425337', '2010-02-08', '01:40:27.425337';"
> Current (2.4.3) behavior:
>  dt
> Out[28]: datetime.datetime(2012, 6, 27, 16, 11, 33, 125585)
> cur1.mogrify("SELECT %s, %s, %s;", (dt,, dt.time()))
> Out[30]: "SELECT '2012-06-27T16:11:33.125585'::timestamp,
> '2012-06-27'::date, '16:11:33.125585'::time;"
> Note the addition of the casts. This is causing problems when using the
> hstore adapter as hstore expects a plain string. Is there a way to get
> around this?

The cast were introduced because PostgreSQL 9.x is much strictier about
function signatures than the 8.x series. Sometimes functions taking
parameters were not found because of the implicit text->other type cast.

But hstore does exactly the opposite. *sigh*

I don't have a nice solution right now, let's think aout it.


Federico Di Gregorio                         federico(dot)digregorio(at)dndg(dot)it
Studio Associato Di Nunzio e Di Gregorio        
  Gli esseri umani, a volte, sono destinati, per il solo fatto di
   esistere, a fare del male a qualcuno.              -- Haruki Murakami

In response to


psycopg by date

Next:From: Daniele VarrazzoDate: 2012-06-28 09:21:46
Subject: Re: Change in datetime type casting
Previous:From: Adrian KlaverDate: 2012-06-27 23:19:34
Subject: Change in datetime type casting

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group