Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 31137 invoked from network); 19 Dec 2007 11:36:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Dec 2007 11:36:41 -0000 Received: (qmail 94694 invoked by uid 500); 19 Dec 2007 11:36:30 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 94675 invoked by uid 500); 19 Dec 2007 11:36:30 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 94664 invoked by uid 99); 19 Dec 2007 11:36:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2007 03:36:30 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [217.24.207.26] (HELO mail.seitenbau.net) (217.24.207.26) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2007 11:36:08 +0000 Received: from [192.168.15.18] (helo=www.seitenbau.net) by router.seitenbau.net with esmtp (Exim 4.43) id 1J4xDc-0000fr-OJ for torque-dev@db.apache.org; Wed, 19 Dec 2007 12:36:10 +0100 In-Reply-To: <8F5843B903F59D4C8C6806BB49A391190505D91B@dukece-mail3.dukece.com> Subject: RE: Question about the handling of default="" in SQL generation To: "Apache Torque Developers List" X-Mailer: Lotus Notes Release 7.0.1 January 17, 2006 Message-ID: From: Thomas Fischer Date: Wed, 19 Dec 2007 12:36:06 +0100 X-MIMETrack: Serialize by Router on www/seitenbau(Release 7.0.1|January 17, 2006) at 19.12.2007 12:36:07 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Spam-Score: -1.4 (-) X-Spam-Report: -1.4 ALL_TRUSTED Passed through trusted hosts only via SMTP X-Virus-Checked: Checked by ClamAV on apache.org If this change is implemented, oracle users would have to be careful because Oracle does not distinguish between an empty string and null (I'm not completely sure what happens, whether oracle sees a default value of ""as illegal or if it does not have any effect). But this is no point against the change. Another question is whether we want to do this during the RC cycle. It might produce different behaviour for users, so I'd rather not change it now but wait a few weeks. Thomas "Greg Monroe" schrieb am 18.12.2007 19:43:06: > I just came across what I think is a long standing bug. However before I > > fix it, I want to make sure that it's not done that way to keep from > breaking some DB syntax restrictions. The bug is this: > > If the schema XML defines a "String" column with a default attribute set > > to "", the SQL generated for a lot of DB's will just ignore this > default. > For example, if you have a column defined as: > > > > The MySQL SQL generated for this column in the CREATE TABLE statement > will be: > > x VARCHAR(254) NOT NULL, > > The default value of "" gets ignored. This doesn't effect records > stored via > Torque objects, because they set the default value and update all field. > However, > if you do some non-Torque inserts, these fail if you don't specify all > the fields. > > The problem is in the Column.getSqlString() code. This ignores both > null and > empty string default values. The fix would skip null and empty string > values for > nonTextType fields but add DEFAULT '' to TextType fields if the default > is "". > E.g. type="INTEGER" default="" would NOT have DEFAULT '' added but > type="LONGVARCHAR" would. > > However, this change would effect the SQL generated for a majority of > the > DB types (only a handfull, like MS SQL don't use this method.. but then > again... MS SQL generates the correct SQL :) ). > > As far as I can tell, the SQL standard says all columns in CREATE TABLE > can > have a DEFAULT [exp] option where [exp] needs to result in the correct > data > type. So it should be within the standards. > > Anyone know a reason NOT to do this? E.g., a DB type that doesn't allow > > '' as default values? > > Greg Monroe (919)680-5050 > C&IS Solutions Team Lead > Duke Corporate Education, Inc. > 330 Blackwell St. > Durham, NC 27701 > > > > > > DukeCE Privacy Statement: > Please be advised that this e-mail and any files transmitted with > it are confidential communication or may otherwise be privileged or > confidential and are intended solely for the individual or entity > to whom they are addressed. If you are not the intended recipient > you may not rely on the contents of this email or any attachments, > and we ask that you please not read, copy or retransmit this > communication, but reply to the sender and destroy the email, its > contents, and all copies thereof immediately. Any unauthorized > dissemination, distribution or copying of this communication is > strictly prohibited. --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org