From: Arthur Axel "fREW" Schmidt Date: Thu, 11 Jun 2009 18:12:38 +0000 (+0000) Subject: updated _resolve_column_source to _resolve_column_info as per ribasushi's suggestion X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c29f2c6d6a24e683b7f6d673997f59e1b16dfb3b;p=dbsrgits%2FDBIx-Class-Historic.git updated _resolve_column_source to _resolve_column_info as per ribasushi's suggestion --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 69aca89..21183cd 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1309,21 +1309,23 @@ sub _resolve_ident_sources { return $alias2source; } -# Takes $ident, [$column_names] +# Takes $ident, \@column_names # -# returns { $column_name => $resultsource, ... } +# returns { $column_name => \%column_info, ... } +# also note: this adds -result_source => $rsrc to the column info # # usage: -# my $col_sources = $self->_resolve_column_sources($ident, [map $_->[0], @{$bind}]); -sub _resolve_column_sources { +# my $col_sources = $self->_resolve_column_info($ident, [map $_->[0], @{$bind}]); +sub _resolve_column_info { 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//; + $col =~ m/^([^\Q${name_sep}\E]*)\Q${name_sep}\E/; my $alias = $1 || 'me'; - $return{$col} = $alias2src->{$alias}; + my $rsrc = $alias2src->{$alias}; + $return{$col} = $rsrc && { %{$rsrc->column_info($col)}, -result_source => $rsrc }; } return \%return; } diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index 8fa8fe4..ff79f54 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -17,13 +17,13 @@ sub _prep_for_execute { $sql .= ';SELECT SCOPE_IDENTITY()' if $op eq 'insert'; my %identity_insert_tables; - my $col_sources = $self->_resolve_column_sources($ident, [map $_->[0], @{$bind}]); + my $col_info = $self->_resolve_column_info($ident, [map $_->[0], @{$bind}]); foreach my $bound (@{$bind}) { my $col = $bound->[0]; - my $rsrc = $col_sources->{$col}; - if ($rsrc && $rsrc->column_info($col)->{is_auto_increment}) { - $identity_insert_tables{$rsrc->from} = 1; + if ($col_info->{$col}->{is_auto_increment}) { + my $table = $col_info->{$col}->{-result_source}->from; + $identity_insert_tables{$table} = 1; } }