From: Peter Rabbitson Date: Fri, 12 Nov 2010 14:58:24 +0000 (+0100) Subject: Backout inconsistent changes to +columns handling X-Git-Tag: v0.08125~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53998003f729b85b27a9e981875cfe5c753e0d28;p=dbsrgits%2FDBIx-Class.git Backout inconsistent changes to +columns handling introduced in 67ba664605de95b5130b55397c7351f53dae4c19 2 years ago --- diff --git a/Changes b/Changes index 6b23ccc..9aa2432 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,8 @@ Revision history for DBIx::Class - Deprecate legacy $rs->search( %condition ) syntax - NULL is now supplied unquoted to all debug-objects, in order to differentiate between a real NULL and the string 'NULL' + - +columns now behaves just like columns by not stripping a + fully-qualified 'as' spec (i.e. foo.bar results in $obj->foo->bar) * Fixes - Fixed read-only attribute set attempt in ::Storage::Replicated diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index b0a1550..8aa1d5f 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -3156,16 +3156,6 @@ sub _resolved_attrs { $_->{as} = [ map { $_ =~ /^\Q$alias.\E(.+)$/ ? $1 : $_ } @{$_->{as}} ]; } - # FIXME !!! - # Blatant bugwardness encoded into multiple tests. - # While columns behaves sensibly, +columns is expected - # to dump *any* foreign columns into the main object - # /me vomits - $selection_pieces->{'+columns'}{as} = [ map - { (split /\./, $_)[-1] } - @{$selection_pieces->{'+columns'}{as}} - ]; - # merge everything for (@sel_pairs) { $attrs->{select} = $self->_merge_attr ($attrs->{select}, $selection_pieces->{$_}{select}); diff --git a/t/60core.t b/t/60core.t index da5531f..630ef8e 100644 --- a/t/60core.t +++ b/t/60core.t @@ -173,13 +173,13 @@ is_deeply( \@cd, [qw/cdid artist title year genreid single_track/], 'column orde $cd = $schema->resultset("CD")->search({ title => 'Spoonful of bees' }, { columns => ['title'] })->next; is($cd->title, 'Spoonful of bees', 'subset of columns returned correctly'); -$cd = $schema->resultset("CD")->search(undef, { include_columns => [ 'artist.name' ], join => [ 'artist' ] })->find(1); +$cd = $schema->resultset("CD")->search(undef, { include_columns => [ { name => 'artist.name' } ], join => [ 'artist' ] })->find(1); is($cd->title, 'Spoonful of bees', 'Correct CD returned with include'); is($cd->get_column('name'), 'Caterwauler McCrae', 'Additional column returned'); # check if new syntax +columns also works for this -$cd = $schema->resultset("CD")->search(undef, { '+columns' => [ 'artist.name' ], join => [ 'artist' ] })->find(1); +$cd = $schema->resultset("CD")->search(undef, { '+columns' => [ { name => 'artist.name' } ], join => [ 'artist' ] })->find(1); is($cd->title, 'Spoonful of bees', 'Correct CD returned with include'); is($cd->get_column('name'), 'Caterwauler McCrae', 'Additional column returned');