[Bast-commits] r5080 - in DBIx-Class/0.08/branches/column_attr: .
lib/DBIx/Class
nigel at dev.catalyst.perl.org
nigel at dev.catalyst.perl.org
Sun Nov 9 08:29:19 GMT 2008
Author: nigel
Date: 2008-11-09 08:29:19 +0000 (Sun, 09 Nov 2008)
New Revision: 5080
Modified:
DBIx-Class/0.08/branches/column_attr/
DBIx-Class/0.08/branches/column_attr/lib/DBIx/Class/ResultSet.pm
Log:
r10070 at Hex: nigel | 2008-11-09 08:29:11 +0000
Reformatting closer to original
Property changes on: DBIx-Class/0.08/branches/column_attr
___________________________________________________________________
Name: svk:merge
- 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10067
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:5073
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
+ 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54993
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
ab17426e-7cd3-4704-a2a2-80b7c0a611bb:/local/dbic_column_attr:10070
bd5ac9a7-f185-4d95-9186-dbb8b392a572:/local/os/bast/DBIx-Class/0.08/trunk:2798
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/cdbicompat_integration:4160
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/complex_join_rels:4589
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/file_column:3920
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/oracle_sequence:4173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/parser_fk_index:4485
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/replication_dedux:4600
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/savepoints:4223
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/storage-ms-access:4142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioning:4578
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:5073
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
Modified: DBIx-Class/0.08/branches/column_attr/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/column_attr/lib/DBIx/Class/ResultSet.pm 2008-11-08 20:43:36 UTC (rev 5079)
+++ DBIx-Class/0.08/branches/column_attr/lib/DBIx/Class/ResultSet.pm 2008-11-09 08:29:19 UTC (rev 5080)
@@ -2070,148 +2070,145 @@
}
sub _resolved_attrs {
- my $self = shift;
- return $self->{_attrs} if $self->{_attrs};
+ my $self = shift;
+ return $self->{_attrs} if $self->{_attrs};
- my $attrs = { %{ $self->{attrs} || {} } };
- my $source = $self->result_source;
- my $alias = $attrs->{alias};
+ my $attrs = { %{ $self->{attrs} || {} } };
+ my $source = $self->result_source;
+ my $alias = $attrs->{alias};
- $attrs->{columns} ||= delete $attrs->{cols} if exists $attrs->{cols};
- my @colbits;
+ $attrs->{columns} ||= delete $attrs->{cols} if exists $attrs->{cols};
+ my @colbits;
- # build columns (as long as select isn't set), include_columns and +columns
- # into a set of as/select hashes
- foreach my $col (
- (
- $attrs->{select} ? ()
- : @{ delete $attrs->{columns} || [ $source->columns ] }
- ),
- (
- $attrs->{include_columns} ? @{ delete $attrs->{include_columns} }
- : ()
- ),
- ( $attrs->{'+colums'} ? @{ delete $attrs->{'+colums'} } : () )
- )
- {
- if ( ref($col) eq 'HASH' ) {
- push( @colbits, $col );
- }
- else {
- push(
- @colbits,
- {
- (
- ( $col =~ m/^\Q${alias}.\E(.+)$/ ) ? $1
- : $col
- ) => (
- ( $col =~ m/\./ ) ? $col
- : "${alias}.${col}"
- )
- }
- );
- }
+ # build columns (as long as select isn't set), include_columns and +columns
+ # into a set of as/select hashes
+ foreach my $col (
+ (
+ $attrs->{select} ? ()
+ : @{ delete $attrs->{columns} || [ $source->columns ] }
+ ),
+ (
+ $attrs->{include_columns} ? @{ delete $attrs->{include_columns} }
+ : ()
+ ),
+ ( $attrs->{'+columns'} ? @{ delete $attrs->{'+columns'} } : () )
+ )
+ {
+ if ( ref($col) eq 'HASH' ) {
+ push( @colbits, $col );
}
-
- # start with initial select items
- if ( $attrs->{select} ) {
- $attrs->{select} =
- ( ref $attrs->{select} eq 'ARRAY' )
- ? [ @{ $attrs->{select} } ]
- : [ $attrs->{select} ];
- $attrs->{as} = (
- $attrs->{as}
- ? (
- ref $attrs->{as} eq 'ARRAY'
- ? [ @{ $attrs->{as} } ]
- : [ $attrs->{as} ]
- )
- : [
- map { m/^\Q${alias}.\E(.+)$/ ? $1 : $_ } @{ $attrs->{select} }
- ]
- );
- }
else {
-
- # otherwise we intialise select & as
- $attrs->{select} = [];
- $attrs->{as} = [];
+ push(
+ @colbits,
+ {
+ (
+ ( $col =~ m/^\Q${alias}.\E(.+)$/ ) ? $1
+ : $col
+ ) => (
+ ( $col =~ m/\./ ) ? $col
+ : "${alias}.${col}"
+ )
+ }
+ );
}
+ }
- # now add colbits to select/as
- push( @{ $attrs->{select} }, map { values( %{$_} ) } @colbits );
- push( @{ $attrs->{as} }, map { keys( %{$_} ) } @colbits );
+ # start with initial select items
+ if ( $attrs->{select} ) {
+ $attrs->{select} =
+ ( ref $attrs->{select} eq 'ARRAY' )
+ ? [ @{ $attrs->{select} } ]
+ : [ $attrs->{select} ];
+ $attrs->{as} = (
+ $attrs->{as}
+ ? (
+ ref $attrs->{as} eq 'ARRAY'
+ ? [ @{ $attrs->{as} } ]
+ : [ $attrs->{as} ]
+ )
+ : [ map { m/^\Q${alias}.\E(.+)$/ ? $1 : $_ } @{ $attrs->{select} } ]
+ );
+ }
+ else {
- my $adds;
- if ( $adds = delete $attrs->{'+select'} ) {
- $adds = [$adds] unless ref $adds eq 'ARRAY';
- push(
- @{ $attrs->{select} },
- map { /\./ || ref $_ ? $_ : "${alias}.$_" } @$adds
- );
- }
- if ( $adds = delete $attrs->{'+as'} ) {
- $adds = [$adds] unless ref $adds eq 'ARRAY';
- push( @{ $attrs->{as} }, @$adds );
- }
+ # otherwise we intialise select & as
+ $attrs->{select} = [];
+ $attrs->{as} = [];
+ }
- $attrs->{from} ||= [ { 'me' => $source->from } ];
+ # now add colbits to select/as
+ push( @{ $attrs->{select} }, map { values( %{$_} ) } @colbits );
+ push( @{ $attrs->{as} }, map { keys( %{$_} ) } @colbits );
- if ( exists $attrs->{join} || exists $attrs->{prefetch} ) {
- my $join = delete $attrs->{join} || {};
+ my $adds;
+ if ( $adds = delete $attrs->{'+select'} ) {
+ $adds = [$adds] unless ref $adds eq 'ARRAY';
+ push(
+ @{ $attrs->{select} },
+ map { /\./ || ref $_ ? $_ : "${alias}.$_" } @$adds
+ );
+ }
+ if ( $adds = delete $attrs->{'+as'} ) {
+ $adds = [$adds] unless ref $adds eq 'ARRAY';
+ push( @{ $attrs->{as} }, @$adds );
+ }
- if ( defined $attrs->{prefetch} ) {
- $join = $self->_merge_attr( $join, $attrs->{prefetch} );
+ $attrs->{from} ||= [ { 'me' => $source->from } ];
- }
+ if ( exists $attrs->{join} || exists $attrs->{prefetch} ) {
+ my $join = delete $attrs->{join} || {};
- $attrs->{from} = # have to copy here to avoid corrupting the original
- [
- @{ $attrs->{from} },
- $source->resolve_join(
- $join, $alias, { %{ $attrs->{seen_join} || {} } }
- )
- ];
+ if ( defined $attrs->{prefetch} ) {
+ $join = $self->_merge_attr( $join, $attrs->{prefetch} );
}
- $attrs->{group_by} ||= $attrs->{select}
- if delete $attrs->{distinct};
- if ( $attrs->{order_by} ) {
- $attrs->{order_by} = (
- ref( $attrs->{order_by} ) eq 'ARRAY'
- ? [ @{ $attrs->{order_by} } ]
- : [ $attrs->{order_by} ]
- );
- }
- else {
- $attrs->{order_by} = [];
- }
+ $attrs->{from} = # have to copy here to avoid corrupting the original
+ [
+ @{ $attrs->{from} },
+ $source->resolve_join(
+ $join, $alias, { %{ $attrs->{seen_join} || {} } }
+ )
+ ];
- my $collapse = $attrs->{collapse} || {};
- if ( my $prefetch = delete $attrs->{prefetch} ) {
- $prefetch = $self->_merge_attr( {}, $prefetch );
- my @pre_order;
- my $seen = $attrs->{seen_join} || {};
- foreach my $p ( ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch) ) {
+ }
- # bring joins back to level of current class
- my @prefetch =
- $source->resolve_prefetch( $p, $alias, $seen, \@pre_order,
- $collapse );
- push( @{ $attrs->{select} }, map { $_->[0] } @prefetch );
- push( @{ $attrs->{as} }, map { $_->[1] } @prefetch );
- }
- push( @{ $attrs->{order_by} }, @pre_order );
- }
- $attrs->{collapse} = $collapse;
+ $attrs->{group_by} ||= $attrs->{select}
+ if delete $attrs->{distinct};
+ if ( $attrs->{order_by} ) {
+ $attrs->{order_by} = (
+ ref( $attrs->{order_by} ) eq 'ARRAY'
+ ? [ @{ $attrs->{order_by} } ]
+ : [ $attrs->{order_by} ]
+ );
+ }
+ else {
+ $attrs->{order_by} = [];
+ }
- if ( $attrs->{page} ) {
- $attrs->{offset} ||= 0;
- $attrs->{offset} += ( $attrs->{rows} * ( $attrs->{page} - 1 ) );
+ my $collapse = $attrs->{collapse} || {};
+ if ( my $prefetch = delete $attrs->{prefetch} ) {
+ $prefetch = $self->_merge_attr( {}, $prefetch );
+ my @pre_order;
+ my $seen = $attrs->{seen_join} || {};
+ foreach my $p ( ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch) ) {
+
+ # bring joins back to level of current class
+ my @prefetch =
+ $source->resolve_prefetch( $p, $alias, $seen, \@pre_order, $collapse );
+ push( @{ $attrs->{select} }, map { $_->[0] } @prefetch );
+ push( @{ $attrs->{as} }, map { $_->[1] } @prefetch );
}
+ push( @{ $attrs->{order_by} }, @pre_order );
+ }
+ $attrs->{collapse} = $collapse;
- return $self->{_attrs} = $attrs;
+ if ( $attrs->{page} ) {
+ $attrs->{offset} ||= 0;
+ $attrs->{offset} += ( $attrs->{rows} * ( $attrs->{page} - 1 ) );
+ }
+
+ return $self->{_attrs} = $attrs;
}
sub _rollout_attr {
More information about the Bast-commits
mailing list