Re: Range type adaptation implemented

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Range type adaptation implemented
Дата
Msg-id CA+mi_8b1dr5S0BM0KidDVX7j0_Seh5CGLs4vNiu40VEj3=MQ7g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Range type adaptation implemented  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: Range type adaptation implemented  ("Jonathan S. Katz" <jonathan.katz@excoventures.com>)
Список psycopg
On Mon, Sep 24, 2012 at 10:45 AM, Karsten Hilbert
<Karsten.Hilbert@gmx.net> wrote:
> On Mon, Sep 24, 2012 at 09:56:14AM +0100, Daniele Varrazzo wrote:
>
>> The funniest surprise I've had during the development
>> was an error creating the object TextRange('#', '$') in the database.
>> It should be possible as
>>
>>     >>> ord('#'), ord('$')
>>     (35, 36)
>>
>> but PG insisted that "range lower bound must be less than or equal to
>> range upper bound". Well, turns out that:
>>
>>     postgres=# select ascii('#') < ascii('$'), '#' < '$';
>>      ?column? | ?column?
>>     ----------+----------
>>      t        | f
>>     (1 row)
>
> This does not seem intuitive but is probably quite logical:
>
> While
>
>         ascii('#') < ascii('$')
>
> eventually compares numerical values (35 and 36) the comparison
>
>         '#' < '$'
>
> operates on characters the sorting order (<) of which
> depends on the lcoale in use.

That's right: the reason is the locale. select '#' collate "C" < '$'
collate "C" returns true as naively expected.

-- Daniele


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

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