[Opensource] DBObject.clear() does not "clear" boolean fields - bug or feature

milend milend at ansco.com
Wed Jun 12 08:01:59 PDT 2002


Hi,

We are having some problems with boolean fields in Expresso v4.1.
When we execute SQL query using new instance of a particular DBObject,
(for example:
DBObj myDBObj=new DBObj();
myDBObj.setField("id","1");
Vector v=myDBObj.searchAndRetrieve();
)
the query result set contains all the records we expect.
But if we want to reuse the same DBObject and just execute .clear()
- result set contains only the records that have boolean fields set to 
"false".
(
myDBObj.clear();
myDBObj.setField("id","1");
Vector v=myDBObj.searchAndRetrieve();
)

In Expresso DBObject, when DBObject.clear() is invoked the following 
fragment is executed:
setField(oneField.getName(), "");

and later in setField(String,String) we have:
....
if (oneField.getTypeString().equalsIgnoreCase("boolean")) {
                    if (fieldValue.equalsIgnoreCase("Y") || 
fieldValue.equalsIgnoreCase("t")
                                || fieldValue.equalsIgnoreCase("true")) {
                        fieldValue = getBooleanFieldValue(true);
                    } else {
                        fieldValue = getBooleanFieldValue(false);
                    }
                }
....
The outcome is that the boolean fields will be set to "false".
Hence when one does searchAndRetrieve() only the records with  "false" 
value will be returned.
At least we think this is causing the trouble - but this is what we 
encounter.
Do you have any solution for that problem?
Or this is the way that method DBObject.clear() is supposed to work?
Thank you in advance!
Milen




More information about the Opensource mailing list