[Bast-commits] r8669 - in
DBIx-Class/0.08/branches/resultset-remove-columns: .
lib/DBIx/Class t/search
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Sat Feb 13 00:24:05 GMT 2010
Author: frew
Date: 2010-02-13 00:24:05 +0000 (Sat, 13 Feb 2010)
New Revision: 8669
Modified:
DBIx-Class/0.08/branches/resultset-remove-columns/Changes
DBIx-Class/0.08/branches/resultset-remove-columns/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/resultset-remove-columns/t/search/select_chains.t
Log:
revert my incorrect method of remove-column stuff
Modified: DBIx-Class/0.08/branches/resultset-remove-columns/Changes
===================================================================
--- DBIx-Class/0.08/branches/resultset-remove-columns/Changes 2010-02-12 19:43:20 UTC (rev 8668)
+++ DBIx-Class/0.08/branches/resultset-remove-columns/Changes 2010-02-13 00:24:05 UTC (rev 8669)
@@ -1,6 +1,5 @@
Revision history for DBIx::Class
- - Add remove-columns/remove-select/remove-as search attributes
- Add as_subselect_rs to DBIC::ResultSet from
DBIC::Helper::ResultSet::VirtualView::as_virtual_view
- Depend on newest bugfixed Moose
Modified: DBIx-Class/0.08/branches/resultset-remove-columns/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/resultset-remove-columns/lib/DBIx/Class/ResultSet.pm 2010-02-12 19:43:20 UTC (rev 8668)
+++ DBIx-Class/0.08/branches/resultset-remove-columns/lib/DBIx/Class/ResultSet.pm 2010-02-13 00:24:05 UTC (rev 8669)
@@ -2778,27 +2778,10 @@
$attrs->{columns} ||= delete $attrs->{cols} if exists $attrs->{cols};
my @colbits;
- my @del_colbits;
# build columns (as long as select isn't set) into a set of as/select hashes
unless ( $attrs->{select} ) {
- my @del_cols = @{ delete $attrs->{'remove-columns'} || [] };
-
- for (@del_cols) {
- if ( ref $_ eq 'HASH' ) {
- push @del_colbits, $_
- } else {
- my $key = /^\Q${alias}.\E(.+)$/
- ? "$1"
- : "$_";
- my $value = /\./
- ? "$_"
- : "${alias}.$_";
- push @del_colbits, { $key => $value };
- }
- }
-
my @cols;
if ( ref $attrs->{columns} eq 'ARRAY' ) {
@cols = @{ delete $attrs->{columns}}
@@ -2823,6 +2806,24 @@
}
}
+ # add the additional columns on
+ foreach (qw{include_columns +columns}) {
+ if ( $attrs->{$_} ) {
+ my @list = ( ref($attrs->{$_}) eq 'ARRAY' )
+ ? @{ delete $attrs->{$_} }
+ : delete $attrs->{$_};
+ for (@list) {
+ if ( ref($_) eq 'HASH' ) {
+ push @colbits, $_
+ } else {
+ my $key = ( split /\./, $_ )[-1];
+ my $value = ( /\./ ? $_ : "$alias.$_" );
+ push @colbits, { $key => $value };
+ }
+ }
+ }
+ }
+
# start with initial select items
if ( $attrs->{select} ) {
$attrs->{select} =
@@ -2857,44 +2858,6 @@
push @{ $attrs->{select} }, map values %{$_}, @colbits;
push @{ $attrs->{as} }, map keys %{$_}, @colbits;
- if ( @del_colbits) {
- push @{ $attrs->{'remove-select'} }, map values( %{$_} ), @del_colbits;
- push @{ $attrs->{'remove-as'} }, map keys( %{$_} ), @del_colbits;
- }
-
- if (my $dels = delete $attrs->{'remove-select'}) {
- for my $del (@{$dels}) {
- $attrs->{select} = [grep !ref $_ && $_ ne $del, @{$attrs->{select}}];
- }
- }
-
- if (my $dels = delete $attrs->{'remove-as'}) {
- for my $del (@{$dels}) {
- $attrs->{as} = [grep !ref $_ && $_ ne $del, @{$attrs->{as}}];
- }
- }
-
- # add the additional columns on
- @colbits = ();
- foreach (qw{include_columns +columns}) {
- if ( $attrs->{$_} ) {
- my @list = ( ref($attrs->{$_}) eq 'ARRAY' )
- ? @{ delete $attrs->{$_} }
- : delete $attrs->{$_};
- for (@list) {
- if ( ref($_) eq 'HASH' ) {
- push @colbits, $_
- } else {
- my $key = ( split /\./, $_ )[-1];
- my $value = ( /\./ ? $_ : "$alias.$_" );
- push @colbits, { $key => $value };
- }
- }
- }
- }
- push( @{ $attrs->{select} }, map { values( %{$_} ) } @colbits );
- push( @{ $attrs->{as} }, map { keys( %{$_} ) } @colbits );
-
if ( my $adds = delete $attrs->{'+select'} ) {
$adds = [$adds] unless ref $adds eq 'ARRAY';
push @{ $attrs->{select} },
@@ -3258,27 +3221,6 @@
Deprecated. Acts as a synonym for L</+columns> for backward compatibility.
-=head2 remove-columns
-
-=over 4
-
-=item Value: ArrayRef[ Str | HashRef[Str] ] \@columns
-
-=back
-
-Indicates columns to be removed from the currently selected columns from storage.
-For example:-
-
- $schema->resultset('CD')->search(undef, {
- '+columns' => [qw{artist.name artist.id}],
- join => ['artist']
- })->search(undef, {
- 'remove-columns' => [qw{artist.id}],
- });
-
-would return all CDs and include a 'name' column to the information
-passed to object inflation.
-
=head2 select
=over 4
Modified: DBIx-Class/0.08/branches/resultset-remove-columns/t/search/select_chains.t
===================================================================
--- DBIx-Class/0.08/branches/resultset-remove-columns/t/search/select_chains.t 2010-02-12 19:43:20 UTC (rev 8668)
+++ DBIx-Class/0.08/branches/resultset-remove-columns/t/search/select_chains.t 2010-02-13 00:24:05 UTC (rev 8669)
@@ -37,11 +37,6 @@
{
columns => [ 'year' ],
} => 'SELECT me.year FROM cd me',
-
- {
- '+columns' => [ 'cdid' ],
- 'remove-columns' => [qw{cdid year}],
- } => 'SELECT me.cdid FROM cd me',
);
my $rs = $schema->resultset('CD');
More information about the Bast-commits
mailing list