Return-Path: Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 32404 invoked from network); 25 Apr 2003 22:53:09 -0000 Received: from ns-3.csir.co.za (HELO wabe.csir.co.za) (146.64.10.166) by daedalus.apache.org with SMTP; 25 Apr 2003 22:53:09 -0000 Received: from [192.168.0.234] ([146.64.12.55]) by wabe.csir.co.za (8.11.6/8.11.6) with ESMTP id h3PMr4a05712 for ; Sat, 26 Apr 2003 00:53:06 +0200 Subject: Re: Postgres aapter bug From: Thomas Fogwill To: torque-dev@db.apache.org In-Reply-To: <1051307703.8107.30.camel@raleigh> References: <1051283568.558.33.camel@orthanc> <1051290214.8110.25.camel@raleigh> <1051306923.678.69.camel@orthanc> <1051307703.8107.30.camel@raleigh> Content-Type: text/plain Organization: CSIR - iComtek Message-Id: <1051310936.691.103.camel@orthanc> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 26 Apr 2003 00:48:56 +0200 Content-Transfer-Encoding: 7bit X-MailScanner-Information: Please contact the ISP for more information X-MailScanner: Found to be clean X-MailScanner-SpamCheck: not spam, SpamAssassin (score=-1.8, required 9, IN_REP_TO, NOSPAM_INC, QUOTED_EMAIL_TEXT, REFERENCES, SIGNATURE_SHORT_DENSE, SPAM_PHRASE_00_01) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 > > > > Senior Systems Architect/Developer: ICT Programme > > > > Information, Communication and Space Technology > > > > CSIR > > > > Tel: +27 12 841 3155 -- Thomas Fogwill 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.