Re: operator varchar = integer

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Daniel Schuchardt <daniel_schuchardt(at)web(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: operator varchar = integer
Date: 2008-05-05 18:13:51
Message-ID: 481F4E5F.7040204@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tino Wildenhain 2008-05-05 18:18:19 Re: operator is not unique: integer || integer
Previous Message Lee Feigenbaum 2008-05-05 18:03:09 Re: bytea and character encoding when inserting escaped literals