From: Alexander Hartmaier Date: Mon, 25 Oct 2010 15:16:54 +0000 (+0200) Subject: handle DBIx::Class change for find which throws an exception since version > 0.08123 X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate;a=commitdiff_plain;h=94b45cc97e1539467d537de1c64466e68dc50de9 handle DBIx::Class change for find which throws an exception since version > 0.08123 --- diff --git a/dist.ini b/dist.ini index 03ff85e..bb67d60 100644 --- a/dist.ini +++ b/dist.ini @@ -41,6 +41,7 @@ DBD::SQLite = 1.21 Readonly = 1.03 List::MoreUtils = 0.22 Carp::Clan = 6.04 +Try::Tiny = 0.07 [Prereqs / TestRequires] Test::More = 0.88 diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 2015860..ebb29f2 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -37,6 +37,7 @@ package DBIx::Class::ResultSet::RecursiveUpdate::Functions; use Carp::Clan qw/^DBIx::Class|^HTML::FormHandler|^Try::Tiny/; use Scalar::Util qw( blessed ); use List::MoreUtils qw/ any /; +use Try::Tiny; sub recursive_update { my %params = @_; @@ -86,14 +87,18 @@ sub recursive_update { if ( !defined $object && scalar @missing == 0 ) { # warn 'finding by: ' . Dumper( $updates ); use Data::Dumper; - $object = $self->find( $updates, { key => 'primary' } ); + try { + $object = $self->find( $updates, { key => 'primary' } ); + }; } $updates = { %$updates, %$resolved }; @missing = grep { !exists $resolved->{$_} } @missing; if ( !defined $object && scalar @missing == 0 ) { - # warn 'finding by +resolved: ' . Dumper( $updates ); use Data::Dumper; - $object = $self->find( $updates, { key => 'primary' } ); + # warn 'finding by +resolved: ' . Dumper( $updates ); use Data::Dumper; + try { + $object = $self->find( $updates, { key => 'primary' } ); + }; } $object = $self->new( {} )