Search the web
Sign In
New User? Sign Up
SimpleORM
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Handling of "" when it means NULL in the database   Message List  
Reply | Forward Message #1546 of 1851 |
Re: [SimpleORM] Handling of "" when it means NULL in the database

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?"




Mon Apr 14, 2008 3:30 am

berglas@...
Send Email Send Email

Forward
Message #1546 of 1851 |
Expand Messages Author Sort by Date

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), ""...
hkara1
Offline Send Email
Apr 9, 2008
9:39 am

Your approach sounds reasonable. There is an isEmpty test in SField. Anthony ... Spreadsheet Detective, Southern Cross Software Queensland Pty Limited 54...
Anthony & Melissa Ber...
berglas@...
Send Email
Apr 14, 2008
3:30 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help