From: Peter Rabbitson Date: Mon, 3 Aug 2009 10:41:32 +0000 (+0000) Subject: Sanify unqualified column bindtype handling X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a34702e855e9de44e748595a721b171fbb79a836;p=dbsrgits%2FDBIx-Class-Historic.git Sanify unqualified column bindtype handling Silence a warning when using a custom {from} --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index b7ba496..9fba9fc 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2928,7 +2928,7 @@ sub _joinpath_aliases { for my $j (@$fromspec) { next if ref $j ne 'ARRAY'; - next if $j->[0]{-relation_chain_depth} < $cur_depth; + next if ($j->[0]{-relation_chain_depth} || 0) < $cur_depth; my $jpath = $j->[0]{-join_path}; diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1d1e57b..5a97bb3 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1401,8 +1401,21 @@ sub _select_args { 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 $rs_alias; + # Unqialified column names are nice, but at the same time can be + # rather ambiguous. What we do here is basically go along with + # the loop, adding an unqualified column slot to $bind_attrs, + # alongside the fully qualified name. As soon as we encounter + # another column by that name (which would imply another table) + # we unset the unqualified slot and never add any info to it + # to avoid erroneous type binding. If this happens the users + # only choice will be to fully qualify his column name + + if (exists $bind_attrs->{$col}) { + $bind_attrs->{$col} = {}; + } + else { + $bind_attrs->{$col} = $bind_attrs->{$fqcn}; + } } }