Re: Range type adaptation implemented

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Range type adaptation implemented
Дата
Msg-id CA+mi_8Ze2Fr6gc1qKYxK4MFO2URQQbL8sU4DUvdb8WCxQy6CiA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Range type adaptation implemented  ("Jonathan S. Katz" <jonathan.katz@excoventures.com>)
Ответы Re: Range type adaptation implemented  (Jacob Kaplan-Moss <jacob@jacobian.org>)
Список psycopg
On Mon, Sep 24, 2012 at 5:29 PM, Jonathan S. Katz
<jonathan.katz@excoventures.com> wrote:

> With that said, referencing this line:
>
> https://github.com/dvarrazzo/psycopg/blob/range-type/lib/_range.py#L135
>
> Because those sets of operators are supposed on the Postgres side, perhaps
> we could provide an error message indicating that?  That way if someone
> needs to look at the comparisons between ranges they know the database
> operators.  So maybe:
>
> "Range objects cannot be ordered - please refer to the PostgreSQL
> documentation to perform this operation in the database"

Yeah, we could improve that message. The important thing was to
disallow r1 < r2 at all, because the Python "object" type by default
implements these operators as pointer comparison: if an user gets a
result True or False out of ranges comparison he may think the
operation is allowed and returns something meaningful...

I've actually not found any object that *doesn't compare* in Python,
so I don't know exactly how to deal with it. There are objects with
partial ordering around (e.g. sets) but they return False if not
comparable.

    >>> set('a') < set('b')
    False
    >>> set('a') > set('b')
    False

We could return False to any comparison but still it's not like "you
cannot do that, mate". Anybody knows an example of unorderable object
in Python? Is there anything more appropriate than throwing TypeError?

-- Daniele


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

Предыдущее
От: "Jonathan S. Katz"
Дата:
Сообщение: Re: Range type adaptation implemented
Следующее
От: Jacob Kaplan-Moss
Дата:
Сообщение: Re: Range type adaptation implemented