[Opensource] Integer to NULL fields
Michael Rimov
rimovm at centercomp.com
Sat Sep 7 04:11:59 PDT 2002
Kris T. and all interested :)
Good news for me... I wrote the following test case:
Test1 oneTest = new Test1();
oneTest.setDBName(TestSystemInitializer.getTestContext());
oneTest.setField("TestKey", "1");
oneTest.add();
oneTest.clear();
oneTest.setField("TestKey","1");
if (!oneTest.find()) {
fail("Unable to locate record we just updated");
}
assertTrue("Test field must be null", oneTest.isFieldNull("IntTest"));
And I WAS able to prove that the isFieldNull() stuff in quoteIfNeeded WAS
indeed saving data to the database as null as expected.
Now the bad news for me :)
When we read the data from the database, it was reading "" instead of null.
Turns out that the problem lay in several places, and most notoriously at
DBConnection.getString(colNum), which would return empty string if the
field was null.
I have gone through and found all the references to it and made sure that
returning null won't break anything. Anything suspicious that didn't
directly affect our problem I wrapped with StringUtil.notNull(). So the
unit tests pass.
Thanks for keeping on it... it keeps it near the "top" portion of my
cranium instead of buried in the cobweb laden dungeons :)
Let me know if this still doesn't do it.
-Mike
More information about the Opensource
mailing list