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}||{}} };
push( @{ $attrs->{as} }, @$adds );
}
- $attrs->{from} ||= [ { $self->{attrs}{alias} => $source->from } ];
+ $attrs->{from} ||= [ {
+ -result_source => $source,
+ -alias => $self->{attrs}{alias},
+ $self->{attrs}{alias} => $source->from,
+ } ];
if ( exists $attrs->{join} || exists $attrs->{prefetch} ) {
my $join = delete $attrs->{join} || {};
my $p = $paths;
$p = $p->{$_} ||= {} for @{$j->[0]{-join_path}};
- push @{$p->{-join_aliases} }, $j->[0]{-join_alias};
+ push @{$p->{-join_aliases} }, $j->[0]{-alias};
}
return $paths;
$type = $rel_info->{attrs}{join_type} || '';
$force_left->{force} = 1 if lc($type) eq 'left';
}
- return [ { $as => $self->related_source($join)->from,
+
+ my $rel_src = $self->related_source($join);
+ return [ { $as => $rel_src->from,
+ -result_source => $rel_src,
-join_type => $type,
-join_path => [@$jpath, $join],
- -join_alias => $as,
+ -alias => $as,
-relation_chain_depth => $seen->{-relation_chain_depth} || 0,
},
$self->_resolve_condition($rel_info->{cond}, $as, $alias) ];
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' =>
if($dbh && !$self->unsafe) {
my $weak_self = $self;
- weaken($weak_self);
+ Scalar::Util::weaken($weak_self);
$dbh->{HandleError} = sub {
if ($weak_self) {
$weak_self->throw_exception("DBI Exception: $_[0]");
sub _prep_for_execute {
my ($self, $op, $extra_bind, $ident, $args) = @_;
- if( blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ if( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
$ident = $ident->from();
}
sub insert {
my ($self, $source, $to_insert) = @_;
-
+
my $ident = $source->from;
my $bind_attributes = $self->source_bind_attributes($source);
my $self = shift @_;
my $source = shift @_;
- my $bind_attrs = {}; ## If ever it's needed...
+ my $bind_attrs = $self->source_bind_attributes($source);
return $self->_execute('delete' => [], $source, $bind_attrs, @_);
}
( map { $_ => $attrs->{$_} } (@in_order_attrs) )
};
}
- my $bind_attrs = {}; ## Future support
+
+ # the reason this is so contrived is because we have several tables in
+ # from, each with its own set of bindattrs
+ my $alias2source;
+ if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ $alias2source->{$ident->alias} = $ident;
+ }
+ elsif (ref $ident eq 'ARRAY') {
+
+ for (@$ident) {
+ my $tabinfo;
+ if (ref $_ eq 'HASH') {
+ $tabinfo = $_;
+ }
+ if (ref $_ eq 'ARRAY' and ref $_->[0] eq 'HASH') {
+ $tabinfo = $_->[0];
+ }
+
+ $alias2source->{$tabinfo->{-alias}} = $tabinfo->{-result_source}
+ if ($tabinfo->{-result_source});
+ }
+ }
+
+ my $bind_attrs = {};
+ 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';
+ }
+ }
+
my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order);
if ($attrs->{software_limit} ||
$sql_maker->_default_limit_syntax eq "GenericSubQ") {