db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fogwill <tfogw...@csir.co.za>
Subject Re: Postgres aapter bug
Date Fri, 25 Apr 2003 22:48:56 GMT
I agree. I truly feel that torque should only support one underlying
type for boolean fields. As you mentioned, postgres has 3 different
underlying types for boolean: 
BIT = boolean
BOOLEANCHAR = char
BOOLEANINT = int2

I cannot see any clean way of determining whether the column is a BIT,
BOOLEANINT, or BOOLEANCHAR inside the Criteria, nor inside the adapter.
Thus, by implication, the adapter can never return a String that will
work for the postgres BIT type (the same probably goes for BOOLEANCHAR,
which is actually a char). Thus, it is (and will remain) essentially
broken. 

The best way to fix this, I think, is to realise that the adapter can
never return the correct string for all 3 types, and to accordingly fix
things on the sql generation side. i.e. Regardless of whether the schema
says BIT, BOOLEANCHAR or BOOLEANINT, always generate boolean columns as
int2. Then the adapter will work for each of the 3 boolean types.

The file src/templates/sql/base/postgresql/db.props seems to hold all
the mappings. Possibly this is where the chnages can be made?

Cheers
Tom


On Fri, 2003-04-25 at 23:55, James A. Hillyerd wrote:
> I'd really like to see it get fixed in Torque, but unfortunately the
> people managing the Torque project don't see it as a priority.  I think
> we PostgreSQL users are few and far between.  =(
> 
> -james
> 
> On Fri, 2003-04-25 at 14:42, Thomas Fogwill wrote:
> > Hi James
> > 
> > Thanks for the info. I agree, this is a real pain.
> > 
> > Anyway, I suppose I'll have to use the modified torque for now, or
> > change my schema to use BOOLEANINT.
> > 
> > Cheers
> > T
> > On Fri, 2003-04-25 at 19:03, James A. Hillyerd wrote:
> > > Hi Thomas,
> > > 
> > > I've submitted a similar patch in the past, I think other people have as
> > > well.  If you look at the patch that went into revision 1.8: "added a DB
> > > adapter method to give a valid boolean value, used it in SqlExpression,
> > > and added tests for the couple variations."  It's exactly what you
> > > propose.  
> > > 
> > > But then someone reverts it for revision 1.10:
> > > http://scarab.tigris.org/issues/show_bug.cgi?id=368
> > > 
> > > Basically every postgresql/torque user has to pay for Scarab's shoddy
> > > database design.  I'm stuck using a modified version of torque for this
> > > very reason.
> > > 
> > > Link to my previous threads on this subject:
> > > 
> > > http://www.mail-archive.com/turbine-torque-dev@jakarta.apache.org/msg01625.html
> > > http://www.mail-archive.com/turbine-torque-dev@jakarta.apache.org/msg00329.html
> > > 
> > > -james
> > > 
> > > On Fri, 2003-04-25 at 08:12, Thomas Fogwill wrote:
> > > > Hi
> > > > 
> > > > There seems to be a bug in the postgres adapter. Postgres expects the
> > > > strings "true" and "false" for boolean fields, but the adapter returns
> > > > "1" and "0".
> > > > 
> > > > Currently, this is what method getBooleanString in
> > > > org.apache.torque.adapter.DBPostgres looks like:
> > > > 
> > > >     /**
> > > >      * Override the default behavior to associate b with null?
> > > >      *
> > > >      * @see org.apache.torque.adapters.DB#getBooleanString
> > > >      */
> > > >     public String getBooleanString(Boolean b)
> > > >     {
> > > >         return (b == null) ? "0" : (Boolean.TRUE.equals(b) ? "1" : "0");
> > > >     }
> > > > 
> > > > 
> > > > I propose that it should be:
> > > > 
> > > >     /**
> > > >      * Override the default behavior. If b is null return
> > > >      * "false", else return b.toString(). 
> > > >      *
> > > >      * @see org.apache.torque.adapters.DB#getBooleanString
> > > >      */
> > > >     public String getBooleanString(Boolean b)
> > > >     {
> > > >         return (b == null) ? "false" : b.toString();
> > > >     }
> > > > 
> > > > 
> > > > A patch is attached.
> > > > 
> > > > -- 
> > > > Thomas Fogwill <tfogwill@csir.co.za>
> > > > Senior Systems Architect/Developer: ICT Programme
> > > > Information, Communication and Space Technology
> > > > CSIR
> > > > Tel: +27 12 841 3155
-- 
Thomas Fogwill <tfogwill@csir.co.za>
Senior Systems Architect/Developer: ICT Programme
Information, Communication and Space Technology
CSIR
Tel: +27 12 841 3155


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Mailscanner thanks transtec Computers for their support.


Mime
View raw message