From: Arthur Axel "fREW" Schmidt Date: Wed, 14 Apr 2010 17:30:46 +0000 (+0000) Subject: working filter column impl X-Git-Tag: v0.08122~72^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7b461f8ace866b0ae912fbda389305933fdf7ae3;p=dbsrgits%2FDBIx-Class.git working filter column impl --- diff --git a/lib/DBIx/Class/FilterColumn.pm b/lib/DBIx/Class/FilterColumn.pm index 7077123..35389ea 100644 --- a/lib/DBIx/Class/FilterColumn.pm +++ b/lib/DBIx/Class/FilterColumn.pm @@ -73,4 +73,32 @@ sub set_value { return $filtered; } +sub update { + my ($self, $attrs, @rest) = @_; + foreach my $key (keys %{$attrs||{}}) { + if ($self->has_column($key) && + exists $self->column_info($key)->{_filter_info}) { + my $val = delete $attrs->{$key}; + $self->set_value($key, $val); + $attrs->{$key} = $self->_unfiltered_column($key, $val) + } + } + return $self->next::method($attrs, @rest); +} + + +sub new { + my ($class, $attrs, @rest) = @_; + my $filtered; + foreach my $key (keys %{$attrs||{}}) { + if ($class->has_column($key) && + exists $class->column_info($key)->{_filter_info} ) { + $attrs->{$key} = $class->_unfiltered_column($key, delete $attrs->{$key}) + } + } + my $obj = $class->next::method($attrs, @rest); + return $obj; +} + + 1; diff --git a/t/row/filter_column.t b/t/row/filter_column.t index 59c01a0..d036f4f 100644 --- a/t/row/filter_column.t +++ b/t/row/filter_column.t @@ -8,8 +8,8 @@ use DBICTest; my $schema = DBICTest->init_schema(); DBICTest::Schema::Artist->load_components('FilterColumn'); DBICTest::Schema::Artist->filter_column(rank => { - filter => sub { warn "FILTERING!"; $_[1] * 2 }, - unfilter => sub {warn "UNFILTERING!"; $_[1] / 2 }, + filter => sub { $_[1] * 2 }, + unfilter => sub { $_[1] / 2 }, }); Class::C3->reinitialize();