From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: Change in datetime type casting |
Date: | 2012-06-28 14:43:18 |
Message-ID: | CA+mi_8av7PH7zzfAYpZ+_8tCaT9VtJg5_sMz0hZcLUEN1q6pRw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
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).
If writing a date in and reading a string out is enough for your
application, you can easily write your own specialized hstore adapter
based on the code in extras.py.
> Bigger question:) Is it possible to turn adaption off for a
> connection/cursor?
No, I think adaptation is currently only global. No, I don't like this
asymmetry with typecasting either.
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2012-06-28 14:52:41 | Re: Change in datetime type casting |
Previous Message | Adrian Klaver | 2012-06-28 14:11:38 | Re: Change in datetime type casting |