From: Peter Rabbitson Date: Tue, 9 Jun 2009 22:52:17 +0000 (+0000) Subject: Merge 'rsrc_in_storage' into 'trunk' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39bdd7a903535b7af7b83e91dd72edf5572a2dae;p=dbsrgits%2FDBIx-Class-Historic.git Merge 'rsrc_in_storage' into 'trunk' --- 39bdd7a903535b7af7b83e91dd72edf5572a2dae diff --cc lib/DBIx/Class/ResultSet.pm index 70159a9,7ef13b5..1586766 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@@ -2428,9 -2435,13 +2428,13 @@@ sub _resolve_from my $attrs = $self->{attrs}; my $from = $attrs->{from} - || [ { $attrs->{alias} => $source->from } ]; + || [ { + -result_source => $source, + -alias => $attrs->{alias}, + $attrs->{alias} => $source->from, + } ]; - my $seen = { %{$attrs->{seen_join}||{}} }; + my $seen = { %{$attrs->{seen_join} || {} } }; # we need to take the prefetch the attrs into account before we # ->_resolve_join as otherwise they get lost - captainL diff --cc lib/DBIx/Class/Storage/DBI.pm index 7be8aab,c1f6b37..3f54e1a --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@@ -7,9 -7,10 +7,9 @@@ use strict use warnings; use Carp::Clan qw/^DBIx::Class/; use DBI; -use DBIx::Class::SQLAHacks; use DBIx::Class::Storage::DBI::Cursor; use DBIx::Class::Storage::Statistics; - use Scalar::Util qw/blessed weaken/; + use Scalar::Util(); use List::Util(); __PACKAGE__->mk_group_accessors('simple' => @@@ -1202,12 -1203,41 +1202,36 @@@ sub _select_args my $sql_maker = $self->sql_maker; $sql_maker->{for} = $for; - my @in_order_attrs = qw/group_by having _virtual_order_by/; - if (List::Util::first { exists $attrs->{$_} } (@in_order_attrs) ) { - $order = { - ($order - ? (order_by => $order) - : () - ), - ( map { $_ => $attrs->{$_} } (@in_order_attrs) ) - }; - } + my $order = { map + { $attrs->{$_} ? ( $_ => $attrs->{$_} ) : () } + (qw/order_by group_by having _virtual_order_by/ ) + }; + - my $bind_attrs = {}; ## Future support + + my $bind_attrs = {}; + + my $alias2source = $self->_resolve_ident_sources ($ident); + + for my $alias (keys %$alias2source) { + my $bindtypes = $self->source_bind_attributes ($alias2source->{$alias}) || {}; + for my $col (keys %$bindtypes) { + + my $fqcn = join ('.', $alias, $col); + $bind_attrs->{$fqcn} = $bindtypes->{$col} if $bindtypes->{$col}; + + # so that unqualified searches can be bound too + $bind_attrs->{$col} = $bind_attrs->{$fqcn} if $alias eq 'me'; + } + } + + # This would be the point to deflate anything found in $condition + # (and leave $attrs->{bind} intact). Problem is - inflators historically + # expect a row object. And all we have is a resultsource (it is trivial + # to extract deflator coderefs via $alias2source above). + # + # I don't see a way forward other than changing the way deflators are + # invoked, and that's just bad... + my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order); if ($attrs->{software_limit} || $sql_maker->_default_limit_syntax eq "GenericSubQ") {