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
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' =>
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") {