0 Replies Latest reply: Feb 24, 2010 11:41 AM by Owain North RSS

    null="#iif(...)#" with ORM?

    Owain North Community Member

      Howdy people

       

      Before ORM came along, I'd always have a null="#iif(myprop EQ "",de('TRUE'), de('FALSE'))#" in my cfqueryparams to stop any properties set by empty form fields from getting into the database.

       

      Is this possible using ORM? So far I've only really played with getting stuff *out* with ORM, but now I've started moving my data input screens over to it. I would've expected that it would be clever enough to not save an empty string to a database, but I can kinda see why they wouldn't want to second-guess what you're after.

       

      The closest thing I can find is in TransferORM, whereby in the main config file you can define global nullvalues for your datatypes, ie if a String is "" then assume that's a null, if a number is 0, that's a null, etc etc. Clearly that's no good to me using Coldfusion.

       

      Short of rewriting all the setters to check for empty strings I really can't figure a way around it. Yes, I could do something on a pre-update trigger but the overhead of having to inspect the metadata of every single property I ever set would be significant and dirty, so I'd rather not do that.

       

      Has anyone got any ideas? I guess I want a nullif="property EQ '' " attribute in my cfc's.

       

      Cheers

      O.