[Opensource] Fix for quoteIfNeeded method in DBObject

larry hamel expresso at codeguild.com
Tue Aug 6 10:28:59 PDT 2002


Here the issue, as I understand it:

Some methods that return values from fields in DBObject return primitives rather than objects.  For example getFieldBoolean() returns boolean, not Boolean. So returning a null is a problem.  As a compromise, we preserved the old contracts, returning primitives, and supplied a new method, isFieldNull(), to be used in situations where null testing is required.

Let us know if you have a better way to handle all of this.  Changing the contract to returned only objects means that a lot of legacy code would break.  In the boolean case, for example, I find it convenient to get back a default of false when the underlying database value is null.

By the way, this list is slow, I've been told, because Sandra is doing hand-filtering for spam.  Since this is the only mailing list (as opposed to the discussion boards where you must post via Web), this mailing list seems to be used for just about every topic.


below is a copy of the email that created isFieldNull().  

Larry

-------------------------

At 10:41 PM 5/23/2002 -0700, you wrote: 
hi,
In a previous email about getFieldBoolean(), I wanted to preserve the legacy contract that getFieldBoolean() returns boolean, not changing it to return a Boolean object that may be null, breaking existing code. However, I think that nulls have to be represented in DBObject somehow, since they are in the DB.
you propose a parallel set of methods to those existing in DBObject, e.g.
int getFieldInt() <-- existing in DBObject 
Integer getFieldInteger() <-- proposed below
but the user has to test for null in the second case. how about just providing that test explicitly in one method?
boolean isFieldNull(String fieldName)
Done and checked into CVS. Good suggestion! We will have to change the SQL generation for Update/Add, etc still. But this will get us the tool we need to do that.
-Mike

At 06:33 AM 8/6/2002, Kris Thompson 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.  Larry you out there?  I will add this to the DBObjectTest object myself tonight and see it the problem truely exist and if the 4.02 fix applies to the latest release.
>
>Related but different, is the purpose of the list to discuss the latest build or the latest stable build?  
>
>BTW.  Could you turn on the nitros on this mail server or maybe add a blower so that our emails get out faster then 4 hours later :)
>
>Kris Thompson
>
>Michael Rimov wrote:
>
>>At 09:19 AM 8/5/2002 -0600, you wrote:
>>
>>>Here the senerio
>>
>>
>>Kris,
>>
>>Are you proposing this against the latest code base in Expresso or 4.02?  Larry Hamel added isFieldNull(), and I THOUGHT using that and a few other tweaks that what you're describing was fixed.
>>
>>If it isn't fixed, then I'll get right to it to get it truly fixed and add a unit test at that.
>>
>>Thanks for the feedback,
>>                                                -Mike
>>
>>_______________________________________________
>>Opensource mailing list
>>Opensource at jcorporate.com
>>http://mail.jcorporate.com/mailman/listinfo/opensource
>>Archives: http://mail.jcorporate.com/pipermail/opensource/
>
>
>
>_______________________________________________
>Opensource mailing list
>Opensource at jcorporate.com
>http://mail.jcorporate.com/mailman/listinfo/opensource
>Archives: http://mail.jcorporate.com/pipermail/opensource/




More information about the Opensource mailing list