[Opensource] Fix for quoteIfNeeded method in DBObject

Kris Thompson kris.thompson at seurat.com
Tue Aug 20 06:59:22 PDT 2002


I don't think is the fix.  The core problem is around this piece of code 
in the same method

 if (oneField.isNumericType()) {
            if (fieldValue.equals("")) {
                return "0";
            }

If the column is nullable and the value is "" then this code is going to 
set it to 0.  If this was a non-nulluable field I would be OK with it 
but sometimes 0 mean something like if this were a ID field.  So when I 
want to set it to "" make it null NOT 0.  Like this

 if ( isNumericType( oneField.getTypeString() ) ) {
            if ( fieldValue.equals( "" ) && oneField.allowsNull() ) {
                return null;
            } else {
                if ( fieldValue.equals( "" ) ) {
                    return "0";
                }
                return fieldValue.trim();
            }
        }

Michael Rimov wrote:

> At 07:33 AM 8/6/2002 -0600, you wrote:
>
>> Yes, I was referring to the 4.02 release but it looks like the latest 
>> release has same problem in the "quoteIfNeeded" method.  I don't see 
>> how the isFieldNull method changed anything.... or how it is even 
>> playing a role in this senerio.
>
>
> Hi Kris,
>
> Ok, I took a look at it and indeed you're right, so I added for a 
> check for isFieldNull() and returned null if it is true.  Also fixed a 
> bug for range values.  If you could check CVS and see if that solves 
> the problem for you I'd appreciate it.
>
>
>> Related but different, is the purpose of the list to discuss the 
>> latest build or the latest stable build?
>
>
> It either one is fine.
>





More information about the Opensource mailing list