Re: Change in datetime type casting

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Change in datetime type casting
Дата
Msg-id 4FEC6FB9.20005@gmail.com
обсуждение исходный текст
Ответ на Re: Change in datetime type casting  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
On 06/28/2012 07:43 AM, Daniele Varrazzo wrote:
> On Thu, Jun 28, 2012 at 3:11 PM, Adrian Klaver <adrian.klaver@gmail.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.klaver@gmail.com



В списке psycopg по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Change in datetime type casting
Следующее
От: Federico Di Gregorio
Дата:
Сообщение: Re: Change in datetime type casting