Re: operator varchar = integer

Поиск
Список
Период
Сортировка
От Tino Wildenhain
Тема Re: operator varchar = integer
Дата
Msg-id 481F4E5F.7040204@wildenhain.de
обсуждение исходный текст
Ответ на Re: operator varchar = integer  (Daniel Schuchardt <daniel_schuchardt@web.de>)
Список pgsql-general
Hi,

Daniel Schuchardt wrote:
> Tino Wildenhain schrieb:
>> Hi,
>>
...
>> Comparing int with text in general does not sound like a very good
>> idea to me. It should be quite easy to write a script to identify
>> such places so you can either change the datatypes (preferred) or
>> add the cast. Then rerun your automated regression tests...
>>
>> Cheers
>> T.
> it is not possible to do this. we also used automatic casting as a feature:
> if a user starts a search, we never check the data type he puts in. in
> 81 postgresql automatically casts the user input in dependece of the
> column. so all our search masks has to be checked to, edit fields need
> to get a data type and so on.
>
> example:
>
> user types 1  -> our application automatically starts a search "LIKE '1%'"
> user types 12  -> our application automatically starts a search "LIKE
> '12%'"
>
> and so on. and it doenst matter if the searchfield is char or integer,
> 81 does it automatically.
> if it is a good or bad thing to do it is another question. it works in
> 81 and so we used this feature.

hum. (yes still think there is a lot of improvement possible) but
you could either change the schema to use text instead of int
or easily identify the places where LIKE is used and cast the left hand
expression explicitely to text. When I think about it you should
actually know for sure which places they are since you probably created
functional indexes?

Also it sounds like you are assembling SQL for queries? In this case
its even more easy to put the casts in place (or change the column
datatype). You mentioned support people - do they write raw SQL?

T.


Вложения

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

Предыдущее
От: postgre@seznam.cz
Дата:
Сообщение: Re: [GENERAL] close database, nomount state
Следующее
От: Tino Wildenhain
Дата:
Сообщение: Re: operator is not unique: integer || integer