From: Arthur Axel "fREW" Schmidt Date: Thu, 11 Jun 2009 17:39:00 +0000 (+0000) Subject: general function to go from column names and ident to result source X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=97ffb440eca53bacb15c9c3b18c8a5c073cf6662;p=dbsrgits%2FDBIx-Class-Historic.git general function to go from column names and ident to result source --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index bff3800..69aca89 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1309,6 +1309,25 @@ sub _resolve_ident_sources { return $alias2source; } +# Takes $ident, [$column_names] +# +# returns { $column_name => $resultsource, ... } +# +# usage: +# my $col_sources = $self->_resolve_column_sources($ident, [map $_->[0], @{$bind}]); +sub _resolve_column_sources { + my ($self, $ident, $colnames) = @_; + my $alias2src = $self->_resolve_ident_sources($ident); + my $name_sep = $self->_sql_maker_opts->{name_sep} || '.'; + my %return; + foreach my $col (@{$colnames}) { + $col =~ s/^([^\Q${name_sep}\E]*)\Q${name_sep}\E//; + my $alias = $1 || 'me'; + $return{$col} = $alias2src->{$alias}; + } + return \%return; +} + sub count { my ($self, $source, $attrs) = @_;