Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: ToBoolean method return correct Boolean values as per


  • From: Barry Lind <blind(at)xythos(dot)com>
  • To: Kim Ho <kho(at)redhat(dot)com>
  • Cc: pgsql-jdbc-list <pgsql-jdbc(at)postgresql(dot)org>
  • Subject: Re: ToBoolean method return correct Boolean values as per
  • Date: Wed, 17 Sep 2003 00:00:55 -0700
  • Message-id: <3F6806A7.90302@xythos.com> <text/plain>

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





Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group