Re: ToBoolean method return correct Boolean values as per - Mailing list pgsql-jdbc

From Barry Lind
Subject Re: ToBoolean method return correct Boolean values as per
Date
Msg-id 3F6806A7.90302@xythos.com
Whole thread Raw
In response to ToBoolean method return correct Boolean values as per JDBC spec  (Kim Ho <kho@redhat.com>)
List pgsql-jdbc
Patch applied.

thanks,
--Barry


Kim Ho wrote:
> Problem:
> - The toBoolean() method treats all input strings that start with T, t,
> or 1 as true. For instance, "The sun is not a star." is evaluated as
> true...
> However, booleans are only supposed to be true if the
> value of the input string is equalsignorecase "True".
> I've left in a single character string "1" and
> a single character string "t" (or "T") for backwards compatibility.
>
> new Boolean("this is not a boolean") produces a Boolean object that
> represents false.
>
> However, when you insert 'this is not a boolean' into a CHAR column and
> use getBoolean to extract it, it returns true.
>
> Fix:
>  - Different check in toBoolean()
>
> Cheers,
>
> Kim
>
>
> ------------------------------------------------------------------------
>
> ? cloudscape.LOG
> Index: org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v
> retrieving revision 1.12
> diff -c -p -c -p -r1.12 AbstractJdbc1ResultSet.java
> *** org/postgresql/jdbc1/AbstractJdbc1ResultSet.java    3 May 2003 20:40:45 -0000    1.12
> --- org/postgresql/jdbc1/AbstractJdbc1ResultSet.java    18 Jun 2003 14:22:43 -0000
> *************** public abstract class AbstractJdbc1Resul
> *** 766,773 ****
>       {
>           if (s != null)
>           {
> !             int c = s.charAt(0);
> !             return ((c == 't') || (c == 'T') || (c == '1'));
>           }
>           return false;        // SQL NULL
>       }
> --- 766,773 ----
>       {
>           if (s != null)
>           {
> !             s = s.trim();
> !             return (s.equalsIgnoreCase("true") || s.equals("1") || s.equalsIgnoreCase("t"));
>           }
>           return false;        // SQL NULL
>       }
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings



pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: rsetMetaData.getColumnCount();
Next
From: Sergio Ramos
Date:
Subject: Connection refused. HELP ME!!!!