general function to go from column names and ident to result source
Arthur Axel "fREW" Schmidt [Thu, 11 Jun 2009 17:39:00 +0000 (17:39 +0000)]
lib/DBIx/Class/Storage/DBI.pm

index bff3800..69aca89 100644 (file)
@@ -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) = @_;