db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James A. Hillyerd" <ja...@whynotown.com>
Subject Re: Postgres aapter bug
Date Tue, 29 Apr 2003 23:35:20 GMT
Matt,

That's just super. ;)

I don't use booleanchar for anything, so I can't verify for sure what
torque stores, but this was the snippet I found doing the Y/N (Peer.vm):

    public static ObjectKey doInsert(Criteria criteria, Connection con)
        throws TorqueException
    {
     #foreach ($col in $table.Columns)
         #set ( $cup=$col.Name.toUpperCase() )
         #if($col.isBooleanInt())
        // check for conversion from boolean to int
        if (criteria.containsKey($cup))
        {
            Object possibleBoolean = criteria.get($cup);
            if (possibleBoolean instanceof Boolean)
            {
                if (((Boolean) possibleBoolean).booleanValue())
                {
                    criteria.add($cup, 1);
                }
                else
                {
                    criteria.add($cup, 0);
                }
            }
         }
         #elseif ($col.isBooleanChar())
        // check for conversion from boolean to Y/N
        if (criteria.containsKey($cup))
        {
            Object possibleBoolean = criteria.get($cup);
            if (possibleBoolean instanceof Boolean)
            {
                if (((Boolean) possibleBoolean).booleanValue())
                {
                    criteria.add($cup, "Y");
                }
                else
                {
                    criteria.add($cup, "N");
                }
            }
         }
         #end
     #end


Anyone with more in depth knowledge want to comment on this?

-james

On Tue, 2003-04-29 at 15:19, Matt Finn wrote:
> Well,
> I guess im not really sure whether the booleanchar will work at all, 
> then.. In the village source the Value class defines isTrue as follows:
> 
>      /**
>       * @return true if (true || t | yes | 1)
>       */
>      private boolean isTrue(String value)
>      {
>          return (value.equalsIgnoreCase ("true") ||
>                  value.equalsIgnoreCase ("t") ||
>                  value.equalsIgnoreCase ("yes") ||
>                  value.equals ("1"));
>      }
> 
> It doesn't check for Y/N. This is what torque uses to grab the boolean 
> value from the db.. So I guess if torque used T/F or 0/1 for booleanchar 
> vals, all would be in good harmony along with the '0'/'1' fix in postgres.
> 
> -matt
> 
> 
> James A. Hillyerd wrote:
> > Hi Matt,
> > 
> > I like your idea.  Seems like postgres will let you select against all
> > three of those column types with a '0' or '1', I was expecting it to
> > barf on the int2.
> > 
> > I think we may run into problems with inserts though, since Torque uses
> > 'Y' and 'N' for booleanchar values.
> > 
> > -james
> > 
> > On Mon, 2003-04-28 at 19:35, Matt Finn wrote:
> > 
> >>Hi,
> >>
> >>I have also been afflicted with that problem.
> >>How about using single quotes for booleans ('0' and '1')? This works 
> >>fine with 7.2 and 7.3 postgres across all three types, although I 
> >>haven't tested any earlier versions.
> >>
> >>postgres=# create table test (one boolean, two char, three int2);
> >>CREATE TABLE
> >>postgres=# insert into test (one,two,three) values ('0','0','0');
> >>INSERT 43810 1
> >>postgres=# insert into test (one,two,three) values ('1','1','1');
> >>INSERT 43811 1
> >>postgres=# select * from test;
> >>  one | two | three
> >>-----+-----+-------
> >>    0 | f   | 0
> >>    1 | t   | 1
> >>(2 rows)
> >>
> >>postgres=#
> >>
> >>
> >>-matt
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> >>For additional commands, e-mail: torque-dev-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
-- 
James A. Hillyerd <james@whynotown.com>
WhyNotOwn.com - http://www.whynotown.com/


Mime
View raw message