QuackFuzed.com is the personal ColdFusion coding blog of Matt Quackenbush. It exists primarily as a place for the author to learn, and hopefully to assist others in learning and/or avoiding some of the same pitfalls and mistakes. (Quack certainly makes enough mistakes daily to make up for the entire ColdFusion community.)

Transfer: Using NULL Dates

Posted on July 9, 2009 at 7:28 PM in Transfer, ColdFusion

The purpose of this post is primarily to assist me in remembering this little tidbit, but hopefully it will be of use to someone else as well.

To date (like the pun?) I have not had to use NULL dates with Transfer, so I had never encountered this issue. However, today I needed to handle them, and so I wrote a couple of lines in my decorator thinking that would properly take care of everything.

[Continue Reading]

Comments
(Comment Moderation is enabled. Your comment will not appear until approved.)

On 7/9/09 at 8:52 PM, Dan Wilson said:

Yeah, that hit me a few times. I'm sure you'll help someone out with this post.

DW

On 8/6/09 at 5:12 AM, Robert Rawlins said:

Ah! This is an excellent post! I had this exact same problem myself recently with NULL dates, I had them configured as nullable in the transfer config and couldn't figure out why it was saving a date when committing the record. I've been adding logic into my controllers to setIsNull() before posting them to be committed.

This solves that issue perfectly! One does ponder as to whether Transfer should be setting the default of nullable fields to their null value rather than now()? I mean, you wouldn't default populate a nullable string field with "empty string" would you?

Perhaps something which needs to be raised for discussion with Mark.

Cheers for the tip anyway Matt, I appreciate it.

Rob

On 8/6/09 at 2:36 PM, Matt Quackenbush said:

@Dan - Looks like you were right. :-)

@Robert - There has been discussion with Mark about it. This behavior was in place long before the NULL settings were added to Transfer. It has just been one of those things that has never been high enough on the priority list to address specifically. Or something like that. I'm paraphrasing, of course. ;-)

On 8/7/09 at 12:24 PM, Robert Rawlins said:

Hey Matt,

Ah I see well I guess we can live with the workaround for now, not long before lovely CF9 ormyness is ready for us to use.

Just as a quick note regarding your script for the configure() method, a more succinct way of doing this would be to simply call setSomeDateNull() which will null the field so you don't have to define the full date/time string.

Rob

On 8/7/09 at 1:47 PM, Matt Quackenbush said:

@Rob - It all boils down to personal preference. Do you want your business logic encapsulated within the business object, or are you okay with having portions of it (e.g. setSomeDateNull()) in another layer? Neither one is necessarily more right or more wrong than the other. For me personally, I prefer it to be in the BO. :-)

On 8/7/09 at 1:51 PM, Matt Quackenbush said:

@Rob - Heh. I just realized that I misunderstood your comment. LMAO

I had totally forgotten about the whole setSomeDateNull() method until you mentioned it. I was thinking you were saying to call that from somewhere else, but I realize now that you meant calling it within the configure() method instead of creating the string. DUH!

Thanks for the tip. I will update the post to reflect the change for future readers.
CodeBassRadio

Latest Articles

Eventually something really brilliant and witty will appear right here.

Calendar

July 2009
S M T W T F S
« Jun   Aug »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Subscribe

Enter a valid email address.

The Obligatory Wish List