[Dbix-class] patch for Helpers::ResultSet::RemoveColumns

Seth Daniel dbix-class at sethdaniel.org
Wed Jun 8 21:56:49 GMT 2011


Hello,

I use both Test::DBIx::Class and ::Helper::ResultSet::RemoveColumns and
today noticed that the latter has a tendency to interfere with the
former.  Specifically the former's 'is_fields' routine. 

I have a small patch for RemoveColumns:

--- lib/DBIx/Class/Helper/ResultSet/RemoveColumns.pm.old  2011-03-14 19:43:28.000000000 -0700
+++ lib/DBIx/Class/Helper/ResultSet/RemoveColumns.pm  2011-06-08 14:41:42.000000000 -0700
@@ -13,7 +13,9 @@
    if ( $attrs->{remove_columns} ) {
       my %rc = map { $_ => 1 } @{$attrs->{remove_columns}};
       $attrs->{columns} = [
-         grep { !$rc{$_} } $self->result_source->columns
+         exists $attrs->{ columns }
+           ? grep { !$rc{$_} } @{ $attrs->{columns} }
+           : grep { !$rc{$_} } $self->result_source->columns
       ]
    }


This returns what RemoveColumns would normally return unless there are alrady
columns listed in $attrs->{columns}.  In that case it simply filters that list
instead of all columns.  I frankly don't know enough about DBIx::Class
internals to know whether this is good enough or not.  So I bring it to this
list.  It does pass my tests and the patch doesn't break the tests for
RemoveColumns.

The above patch applies to Helpers 2.007000.

If wanted I can go into more detail about how the current RemoveColumns causes
false test failures when using Test::DBIx::Class.

Thank you.

-- 
seth /\ sethdaniel.org



More information about the DBIx-Class mailing list