The undef_sets_null feature that alters the behavior of default
columns values will almost certainly go out in the next release (which
is coming soon).  It may or may not be public (depending on if I have
time to do docs and add support for it to the rest of the column
types), but the code will be there.  I still think the name is kind of
lame, however, and I'm open to suggestions.

A brief recap: the existing RDBO behavior for column defaults is to
return the default value when the column value is undef.  So:

package Person;
...
    columns =>
    [
      ...
      name => { type => 'varchar', default => 'John Doe' },
      ...
    ],
...

$p = Person->new;
print $p->name; # John Doe

$p->name('Larry Wall');
print $p->name; # Larry Wall

$p->name(undef);
print $p->name; # John Doe

The new behavior is triggered by setting the undef_sets_null column
attribute.  (In this case, we'll set it directly on the column, but it
can be set class-wide or class-hierarchy-wide.)

name => { type => 'varchar', default => 'John Doe', undef_sets_null => 1 },

The behavior is now:

$p = Person->new;
print $p->name; # John Doe

$p->name('Larry Wall');
print $p->name; # Larry Wall

$p->name(undef);
print $p->name; # undef

---

So, that's the feature.  Anyone have a suggestion for a different name
for undef_sets_null?  Feel free to reverse the boolean nature of the
flag if it better suits your name.

-John

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to