Re: Using boolean '1' in jdbc2

Поиск
Список
Период
Сортировка
От Kaneda K
Тема Re: Using boolean '1' in jdbc2
Дата
Msg-id 5.0.2.1.2.20010914111757.00a94908@dedaletechnology.com
обсуждение исходный текст
Ответ на Re: Using boolean '1' in jdbc2  ("Glenn R. Kronschnabl" <grk@netquotient.com>)
Ответы Re: Using boolean '1' in jdbc2
Список pgsql-jdbc
At 22:58 13/09/2001 -0500, you wrote:
>I'm that person.  I'm not trying to do anything convoluted. ;-)
>
>I have a schema & data from Oracle that uses a 'fake' boolean column.
>(Stupid oracle doesn't support type boolean afaik - uses number).  I
>find the easiest way to adapt the schema & data to postgresql is to
>*not* convert the 'fake' boolean fields (enforced in Oracle using
>constraints) to postgresql boolean but to use either numeric(1) or
>integer.  Why?  Because all my data (already exported) has 0's and 1's
>and it would be a waste to try convert all the data to true/false, which
>postgresql requires for a boolean field.  If there is a trick which
>allows 0's and 1's to be imported into a boolean field, I guess I could
>use that instead!?
>
>So - the submitted patch allows a boolean field to be implemented using
>either numeric or integer fields - I think this is pretty common.  An
>according to the archives, this has been dicussed before.
>
>Glenn

Because the "1" features is not suppossed to be in the spécification, cant
you use a personnal class that is a child of the Resultset and overwrite
the method ?

Then - you don't have to permute all your data and this features (which is
not "standard") won't be added to the Driver.

My 2c

Ps: I personnally does that with my MySQL Driver. I use enum('1','0') for
boolean in MySql.



>On Thu, 2001-09-13 at 14:46, Rene Pijlman wrote:
> > On Thu, 13 Sep 2001 15:29:38 -0400 (EDT), you wrote:
> > >> Bruce Momjian writes:
> > >> > I noticed that jdbc1 getBoolean allows '1', while jdbc2 does not.  The
> > >> > following patch makes jdbc2 accept '1' also.  Is this OK?
> > >>
> > >> Why?  Booleans always come out as 't' or 'f'.
> > >
> > >Someone emailed me privately that they wanted to use '1' for
> > >boolean. No idea why, and no idea why jdbc1 has it.
> >
> > In jdbc1 the string to boolean conversion is implemented within
> > getBoolean() itself, which interprets data from the PostgreSQL
> > backend.
> >
> > In jdbc2 its implemented in a helper method
> > ResultSet.toBoolean(), which is public, probably because its now
> > also used in the new Array feature.
> >
> > Perhaps someone is now using ResultSet.toBoolean() as a utility
> > method. I don't think that's a good idea. Even though its public
> > its not part of any published interface. So anyone who wants to
> > convert 1 to true should use his own method. We could rule this
> > out by declaring the method protected or package (no access
> > specifier).
> >
> > This doesn't explain why jdbc1 accepts '1' though. Anyone?
> >
> > Regards,
> > René Pijlman <rene@lab.applinet.nl>
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


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

Предыдущее
От: Peter T Mount
Дата:
Сообщение: Fw: JDBC Bug Report
Следующее
От: Rene Pijlman
Дата:
Сообщение: Re: Using boolean '1' in jdbc2