From: Matthew Desmarais Date: 2006-03-05T04:56:25+09:00 Subject: Re: Kirbybase Hacks NilClass James Edward Gray II wrote: > On Mar 4, 2006, at 12:04 PM, Jamey Cribbs wrote: > >> What has been kicked around when this question has come up before is >> for me to create something like a NULL class and use this to >> designate a null value in the database, instead of using nil. > > I know I would feel a lot safer with that. The only minus there is > that NULL will be a true value, again with surprising behavior for > people who are expecting normal Ruby. If we have to have one though, > I would prefer this one by far. > >> It would bring up a few other problems, namely, what if someone wants >> to store the string value NULL in a field. But I imagine these could >> be overcome. > > Could it be stored using Kirbybase's escapes (&NULL;)? > > James Edward Gray II > > Without thinking too deeply about this, I came up with using a marker value to designate non-NULL values. When a field is written, use '*' as the first character and then write the field's value. NULL is written as the empty string. When reading a field, test to see if it's the empty string. If it is then your value is NULL, otherwise toss the first character and read your non-null value after that. This is probably pretty naive and it would introduce some extra performance overhead though. Just a thought.