[Dbix-class] update_or_create feature required

Daniel Westermann-Clark daniel at acceleration.net
Mon Apr 10 19:36:24 CEST 2006


On 2006-04-10 07:11:38 +0000, fayland wrote:
> when calling update_or_create, I want to know it's "create" or
> "update" since I want to do different thing according to different
> type. such as not + 1 if it's an "update" and +1 if it's a "create".

update_or_create is designed to be a black box in this respect.  Once
I finish my changes to find (so it searches constraints the same way
update_or_create does now), you'll be able to do your own checks:

my $row = $rs->find(...);
if (defined $row) {
  $row->set_columns(...);
  $row->update;
}
else {
  $row = $rs->create(...);
}

Making update_or_create work differently than other ResultSet methods
that return a Row doesn't seem conducive to a clean API.

-- 
Daniel Westermann-Clark



More information about the Dbix-class mailing list