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

Re: Change in datetime type casting

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Change in datetime type casting
Date: 2012-06-28 14:52:41
Message-ID: 4FEC6FB9.20005@gmail.com (view raw or flat)
Thread:
Lists: psycopg
On 06/28/2012 07:43 AM, Daniele Varrazzo wrote:
> On Thu, Jun 28, 2012 at 3:11 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> wrote:
>
>> Which begs the question why does the adapter not do str(value) when creating
>> the ARRAY?
>
> Because it would give a false promise of working. If I put a date in
> my db, I'm expecting a date to come out: any other result is an error.
> The hstore adapter is documented to take strings mapping: results with
> any other mapping is undefined. A better behaviour could be to
> explicitly raise an explicit exception, but it would be less efficient
> than trusting the user he is using the adapter as documented (see
> HstoreAdapter._getquoted_9(): we adapt the dict.values() list, not
> iterate on each values).

I am not seeing the false promise. hstore is documented to only work 
with string keys and values. I am not entering into a date field but a 
hstore field. I would expect the date to be entered or returned as a 
string. I see nothing wrong with the adapter doing that on my behalf. 
The precedent as it where would be the Python csv module. In fact I may 
just run data through csv to get the effect, though it would be nice not to.


>
> -- Daniele
>


-- 
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com



In response to

psycopg by date

Next:From: Federico Di GregorioDate: 2012-06-28 15:13:15
Subject: Re: Change in datetime type casting
Previous:From: Daniele VarrazzoDate: 2012-06-28 14:43:18
Subject: Re: Change in datetime type casting

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