[Bast-commits] r6576 -
DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue Jun 9 22:48:08 GMT 2009
Author: ribasushi
Date: 2009-06-09 22:48:07 +0000 (Tue, 09 Jun 2009)
New Revision: 6576
Modified:
DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm
Log:
Factor out the $ident resolver
Modified: DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm 2009-06-09 22:31:55 UTC (rev 6575)
+++ DBIx-Class/0.08/branches/rsrc_in_storage/lib/DBIx/Class/Storage/DBI.pm 2009-06-09 22:48:07 UTC (rev 6576)
@@ -931,7 +931,7 @@
if ( $self->debug ) {
@bind = $self->_fix_bind_params(@bind);
-
+
$self->debugobj->query_start( $sql, @bind );
}
}
@@ -1214,29 +1214,10 @@
};
}
- # the reason this is so contrived is because we have several tables in
- # from, each with its own set of bindattrs
- my $alias2source;
- if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
- $alias2source->{$ident->alias} = $ident;
- }
- elsif (ref $ident eq 'ARRAY') {
+ my $bind_attrs = {};
- for (@$ident) {
- my $tabinfo;
- if (ref $_ eq 'HASH') {
- $tabinfo = $_;
- }
- if (ref $_ eq 'ARRAY' and ref $_->[0] eq 'HASH') {
- $tabinfo = $_->[0];
- }
+ my $alias2source = $self->_resolve_ident_sources ($ident);
- $alias2source->{$tabinfo->{-alias}} = $tabinfo->{-result_source}
- if ($tabinfo->{-result_source});
- }
- }
-
- my $bind_attrs = {};
for my $alias (keys %$alias2source) {
my $bindtypes = $self->source_bind_attributes ($alias2source->{$alias}) || {};
for my $col (keys %$bindtypes) {
@@ -1272,6 +1253,35 @@
return @args;
}
+sub _resolve_ident_sources {
+ my ($self, $ident) = @_;
+
+ my $alias2source = {};
+
+ # the reason this is so contrived is that $ident may be a {from}
+ # structure, specifying multiple tables to join
+ if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ $alias2source->{$ident->alias} = $ident;
+ }
+ elsif (ref $ident eq 'ARRAY') {
+
+ for (@$ident) {
+ my $tabinfo;
+ if (ref $_ eq 'HASH') {
+ $tabinfo = $_;
+ }
+ if (ref $_ eq 'ARRAY' and ref $_->[0] eq 'HASH') {
+ $tabinfo = $_->[0];
+ }
+
+ $alias2source->{$tabinfo->{-alias}} = $tabinfo->{-result_source}
+ if ($tabinfo->{-result_source});
+ }
+ }
+
+ return $alias2source;
+}
+
sub count {
my ($self, $source, $attrs) = @_;
More information about the Bast-commits
mailing list