=head2 Differences from Class::DBI
-This will warn when a column is accessed as a hash key.
+If C<DBIC_CDBICOMPAT_HASH_WARN> is true it will warn when a column is accessed as a hash key.
=cut
my $class = ref $obj;
my $id = $obj->id;
- carp "Column '$col' of '$class/$id' was fetched as a hash";
+ carp "Column '$col' of '$class/$id' was fetched as a hash"
+ if $ENV{DBIC_CDBICOMPAT_HASH_WARN};
return $obj->$col();
}
my $class = ref $obj;
my $id = $obj->id;
- carp "Column '$col' of '$class/$id' was stored as a hash";
+ carp "Column '$col' of '$class/$id' was stored as a hash"
+ if $ENV{DBIC_CDBICOMPAT_HASH_WARN};
$obj->$col(shift);
}
BEGIN {
eval "use DBIx::Class::CDBICompat;";
plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
- : (tests=> 8);
+ : (tests=> 9);
}
use lib 't/testlib';
Rating => 'R'
});
+local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 1;
+
warnings_like {
my $rating = $waves->{rating};
$waves->Rating("PG");
$waves->update;
my @films = Film->search( Rating => "PG", Title => "Breaking the Waves" );
is @films, 1, "column updated as hash was saved";
+
+
+warning_is {
+ local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 0;
+ $waves->{rating}
+} '', 'DBIC_CDBICOMPAT_HASH_WARN controls warnings';
\ No newline at end of file