From: Peter Rabbitson Date: Fri, 18 Jul 2014 09:49:49 +0000 (+0200) Subject: Remove duplicate arg-check in create(), adjust exception text X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e84ae5d1931244d9a11cd58488aeaf34e33cf234;p=dbsrgits%2FDBIx-Class-Historic.git Remove duplicate arg-check in create(), adjust exception text --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index b21415e..e81fc82 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2446,7 +2446,7 @@ sub new_result { $self->throw_exception( "new_result takes only one argument - a hashref of values" ) if @_ > 2; - $self->throw_exception( "new_result expects a hashref" ) + $self->throw_exception( "Result object instantiation requires a hashref as argument" ) unless (ref $values eq 'HASH'); my ($merged_cond, $cols_from_relations) = $self->_merge_with_rscond($values); @@ -2747,10 +2747,8 @@ L. =cut sub create { - my ($self, $col_data) = @_; - $self->throw_exception( "create needs a hashref" ) - unless ref $col_data eq 'HASH'; - return $self->new_result($col_data)->insert; + #my ($self, $col_data) = @_; + return shift->new_result(shift)->insert; } =head2 find_or_create diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index fe4a691..5d0f860 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -32,7 +32,7 @@ is(Film->__driver, "SQLite", "Driver set correctly"); } eval { my $duh = Film->insert; }; -like $@, qr/create needs a hashref/, "needs a hashref"; +like $@, qr/Result object instantiation requires a hashref as argument/, "needs a hashref"; ok +Film->create_test_film; diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index 89a59a5..0c751a0 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -46,7 +46,7 @@ eval { my $pj = Film->add_to_actors(\%pj_data) }; like $@, qr/class/, "add_to_actors must be object method"; eval { my $pj = $btaste->add_to_actors(%pj_data) }; -like $@, qr/expects a hashref/, "add_to_actors takes hash"; +like $@, qr/Result object instantiation requires a hashref as argument/, "add_to_actors takes hash"; ok( my $pj = $btaste->add_to_actors(