Hi,
I use SimpleOrm quite a lot, and I have this annoyance that "" is not
treated
as NULL when it should be. In Oracle (and also Informix and maybe others),
"" is the same as NULL, whereas in other databases, "" is distinct
from NULL.
So what I propose is to add the following method in SDriver :
/** method to indicate if the database treats empty strings as null
(default : false) */
public boolean emptyStringIsNull() { return false; }
and to overload it in SDriverOracle :
/** Oracle treats empty strings as null */
public boolean emptyStringIsNull() { return true; }
we can now check for empty strings when we store them, and replace
them with
NULL accordingly. The convertToField in the SFieldString becomes :
//(hk) changed to handle the case where "raw" is "", and empty
strings are
//equivalent to null
Object convertToField(Object raw) {
if (raw == null) return null;
String str = raw.toString();
//Convert the empty string to NULL if this is the internal
representation
//for empty strings (this is the case for Oracle and SQLBase (Unify).
if (SConnection.getDriver().emptyStringIsNull() &&
"".equals(str)) {
str = null;
}
return str;
}
This will avoid missed results because Simpleorm issues "=?" with
values of
"", where it should emit "IS NULL".
Best regards,