Your approach sounds reasonable.
There is an isEmpty test in SField.
Anthony
At 07:39 PM 9/04/2008, hkara1 wrote:
>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,
>
>
Spreadsheet Detective,
Southern Cross Software Queensland Pty Limited
54 Gerler Street
Bardon, Queensland 4065, Australia.
Email: berglas@...
www.SpreadsheetDetective.com
Ph: +61 427 830248 (Australian Eastern Standard Time)
"If the model seems correct only because the numbers look right,
then why build the model in the first place?"