From: Michael G Schwern Date: Wed, 13 Feb 2008 01:26:10 +0000 (-0800) Subject: Hash access no works despite lack of existing accessor method. X-Git-Tag: v0.08240~541^2~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d656262b3d0469fc3216a67d3b9fb070110632bd;p=dbsrgits%2FDBIx-Class.git Hash access no works despite lack of existing accessor method. --- diff --git a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm index 9a006d6..dd02a63 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm @@ -54,7 +54,6 @@ sub _make_columns_as_hash { warn "Skipping mapping $col to a hash key because it exists"; } - next unless $self->can($col); tie $self->{$col}, 'DBIx::Class::CDBICompat::Tied::ColumnValue', $self, $col; } diff --git a/t/cdbi-t/columns_as_hashes.t b/t/cdbi-t/columns_as_hashes.t index a355291..70f887e 100644 --- a/t/cdbi-t/columns_as_hashes.t +++ b/t/cdbi-t/columns_as_hashes.t @@ -7,7 +7,7 @@ use Test::Warn; BEGIN { eval "use DBIx::Class::CDBICompat;"; plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@") - : (tests=> 10); + : ('no_plan'); } use lib 't/testlib'; @@ -66,4 +66,25 @@ warning_is { is $waves->{rating}, "R"; } - \ No newline at end of file + + +{ + no warnings 'redefine'; + no warnings 'once'; + local *Actor::accessor_name_for = sub { + my($class, $col) = @_; + return "movie" if lc $col eq "film"; + return $col; + }; + + require Actor; + + my $actor = Actor->insert({ + name => 'Emily Watson', + film => $waves, + }); + + ok !eval { $actor->film }; + is $actor->{film}->id, $waves->id, + 'hash access still works despite lack of accessor'; +} \ No newline at end of file