[Dbix-class] Populating Instance With Column's Defaults
Skye Shaw
skye.shaw at gmail.com
Wed Feb 9 03:30:36 GMT 2011
Hello,
Is it possible to have DBIC populate a newly created instance with the
underlying table's defaults when a value isn't provided?
Given my code (active defaults to 1):
my $user = $db->resultset('Account')->create({
first_name =>'A',
last_name => 'User'
});
print $user->active; #undef warning
$user = $db->resultset('Account')->find($user->id);
print $user->active; #now it's populated with 1
And this thread:
http://stackoverflow.com/questions/2106504/perl-dbixclass-default-values-when-using-new
The answer appears to be no. If so, what's the reason for this behavior?
Thanks
More information about the DBIx-Class
mailing list