[Bast-commits] r6954 - in
DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class: . Storage
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Jul 2 23:21:29 GMT 2009
Author: ribasushi
Date: 2009-07-02 23:21:28 +0000 (Thu, 02 Jul 2009)
New Revision: 6954
Modified:
DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI.pm
Log:
Some hack consolidation
Modified: DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/ResultSet.pm 2009-07-02 22:24:00 UTC (rev 6953)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/ResultSet.pm 2009-07-02 23:21:28 UTC (rev 6954)
@@ -2861,11 +2861,11 @@
];
}
- if ( $attrs->{order_by} ) {
+ if ( defined $attrs->{order_by} ) {
$attrs->{order_by} = (
ref( $attrs->{order_by} ) eq 'ARRAY'
? [ @{ $attrs->{order_by} } ]
- : [ $attrs->{order_by} ]
+ : [ $attrs->{order_by} || () ]
);
}
@@ -2873,16 +2873,6 @@
$attrs->{group_by} = [ $attrs->{group_by} ];
}
- # If the order_by is otherwise empty - we will use this for TOP limit
- # emulation and the like.
- # Although this is needed only if the order_by is not defined, it is
- # actually cheaper to just populate this rather than properly examining
- # order_by (stuf like [ {} ] and the like)
- my $prefix = $alias . ($source->schema->storage->sql_maker->{name_sep} || '.');
- $attrs->{_virtual_order_by} = [
- map { $prefix . $_ } ($source->primary_columns)
- ];
-
$attrs->{collapse} ||= {};
if ( my $prefetch = delete $attrs->{prefetch} ) {
$prefetch = $self->_merge_attr( {}, $prefetch );
@@ -2898,7 +2888,7 @@
push @{ $attrs->{select} }, @{$attrs->{prefetch_select}};
push @{ $attrs->{as} }, (map { $_->[1] } @prefetch);
- push( @{ $attrs->{order_by} }, @$prefetch_ordering );
+ push( @{$attrs->{order_by}}, @$prefetch_ordering );
$attrs->{_collapse_order_by} = \@$prefetch_ordering;
}
Modified: DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/SQLAHacks.pm 2009-07-02 22:24:00 UTC (rev 6953)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/SQLAHacks.pm 2009-07-02 23:21:28 UTC (rev 6954)
@@ -212,17 +212,25 @@
$order = { %$order }; #copy
my $req_order = $order->{order_by};
- my $limit_order =
- scalar $self->_order_by_chunks ($req_order) # examine normalized version, collapses nesting
- ? $req_order
- : $order->{_virtual_order_by}
- ;
+ # examine normalized version, collapses nesting
+ my $limit_order;
+ if (scalar $self->_order_by_chunks ($req_order)) {
+ $limit_order = $req_order;
+ }
+ else {
+ my $rs_alias = $self->{_dbic_rs_attrs}{alias};
+ $limit_order = [ map
+ { join ('', $rs_alias, $name_sep, $_ ) }
+ ( $self->{_dbic_rs_attrs}{_source_handle}->resolve->primary_columns )
+ ];
+ }
+
my ( $order_by_inner, $order_by_outer ) = $self->_order_directions($limit_order);
my $order_by_requested = $self->_order_by ($req_order);
# generate the rest
- delete $order->{$_} for qw/order_by _virtual_order_by/;
+ delete $order->{order_by};
my $grpby_having = $self->_order_by ($order);
# short circuit for counts - the ordering complexity is needless
Modified: DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI.pm 2009-07-02 22:24:00 UTC (rev 6953)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI.pm 2009-07-02 23:21:28 UTC (rev 6954)
@@ -1376,16 +1376,17 @@
sub _select_args {
my ($self, $ident, $select, $where, $attrs) = @_;
+ my ($alias2source, $root_alias) = $self->_resolve_ident_sources ($ident);
+
my $sql_maker = $self->sql_maker;
$sql_maker->{_dbic_rs_attrs} = {
%$attrs,
select => $select,
from => $ident,
where => $where,
+ _source_handle => $alias2source->{$root_alias}->handle,
};
- my ($alias2source, $root_alias) = $self->_resolve_ident_sources ($ident);
-
# calculate bind_attrs before possible $ident mangling
my $bind_attrs = {};
for my $alias (keys %$alias2source) {
@@ -1445,7 +1446,7 @@
my $order = { map
{ $attrs->{$_} ? ( $_ => $attrs->{$_} ) : () }
- (qw/order_by group_by having _virtual_order_by/ )
+ (qw/order_by group_by having/ )
};
return ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $where, $order, @limit);
More information about the Bast-commits
mailing list