X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=bfd7edf7378e3d23b113b88970782da0396104ff;hb=ed159b8288e4167b653ac92c7c5d16c1e4fed7f1;hp=ca0ee876ffdc1ad5bae2bfe269e9bb3cf8d59303;hpb=b5f4f62f2e5d756401c91f8eb6a5fbe1db28b95e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index ca0ee87..bfd7edf 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}; + } } }