From: Peter Rabbitson Date: Mon, 2 Jun 2014 10:20:45 +0000 (+0200) Subject: Clarify FC/IC conflict exception X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85aee309cf0565da729d43bb0f5677da548ffe34;p=dbsrgits%2FDBIx-Class-Historic.git Clarify FC/IC conflict exception --- diff --git a/lib/DBIx/Class/FilterColumn.pm b/lib/DBIx/Class/FilterColumn.pm index cee647e..687c278 100644 --- a/lib/DBIx/Class/FilterColumn.pm +++ b/lib/DBIx/Class/FilterColumn.pm @@ -9,9 +9,8 @@ sub filter_column { my $colinfo = $self->column_info($col); - $self->throw_exception('FilterColumn does not work with InflateColumn') - if $self->isa('DBIx::Class::InflateColumn') && - defined $colinfo->{_inflate_info}; + $self->throw_exception("FilterColumn can not be used on a column with a declared InflateColumn inflator") + if defined $colinfo->{_inflate_info} and $self->isa('DBIx::Class::InflateColumn'); $self->throw_exception("No such column $col to filter") unless $self->has_column($col); diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index e9cc417..23bc4c9 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -89,9 +89,8 @@ sub inflate_column { my $colinfo = $self->column_info($col); - $self->throw_exception("InflateColumn does not work with FilterColumn") - if $self->isa('DBIx::Class::FilterColumn') && - defined $colinfo->{_filter_info}; + $self->throw_exception("InflateColumn can not be used on a column with a declared FilterColumn filter") + if defined $colinfo->{_filter_info} and $self->isa('DBIx::Class::FilterColumn'); $self->throw_exception("No such column $col to inflate") unless $self->has_column($col); diff --git a/t/row/filter_column.t b/t/row/filter_column.t index 4aa2b28..0ed8edf 100644 --- a/t/row/filter_column.t +++ b/t/row/filter_column.t @@ -121,22 +121,22 @@ CACHE_TEST: { } IC_DIE: { - dies_ok { + throws_ok { DBICTest::Schema::Artist->inflate_column(rank => { inflate => sub {}, deflate => sub {} } ); - } q(Can't inflate column after filter column); + } qr/InflateColumn can not be used on a column with a declared FilterColumn filter/, q(Can't inflate column after filter column); DBICTest::Schema::Artist->inflate_column(name => { inflate => sub {}, deflate => sub {} } ); - dies_ok { + throws_ok { DBICTest::Schema::Artist->filter_column(name => { filter_to_storage => sub {}, filter_from_storage => sub {} }); - } q(Can't filter column after inflate column); + } qr/FilterColumn can not be used on a column with a declared InflateColumn inflator/, q(Can't filter column after inflate column); } # test when we do not set both filter_from_storage/filter_to_storage