From: Matt S Trout Date: Mon, 16 Jan 2006 05:36:37 +0000 (+0000) Subject: Changed result_source to result_source_instance in strategic places X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c49f6295f3c7e07ba4bda6379f3c9f065501d7a;p=dbsrgits%2FDBIx-Class-Historic.git Changed result_source to result_source_instance in strategic places --- diff --git a/lib/DBIx/Class/CDBICompat/ColumnCase.pm b/lib/DBIx/Class/CDBICompat/ColumnCase.pm index d79104d..f0c3453 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnCase.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnCase.pm @@ -17,7 +17,7 @@ sub _register_columns { sub add_columns { my ($class, @cols) = @_; - $class->result_source->add_columns(map lc, @cols); + $class->result_source_instance->add_columns(map lc, @cols); $class->_mk_column_accessors(@cols); } diff --git a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm index 77d6112..59c8348 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm @@ -48,7 +48,7 @@ sub _register_column_group { $class->_column_groups($groups); } -sub all_columns { return shift->result_source->columns; } +sub all_columns { return shift->result_source_instance->columns; } sub primary_column { my ($class) = @_; diff --git a/lib/DBIx/Class/CDBICompat/ImaDBI.pm b/lib/DBIx/Class/CDBICompat/ImaDBI.pm index 144195e..7f645d5 100644 --- a/lib/DBIx/Class/CDBICompat/ImaDBI.pm +++ b/lib/DBIx/Class/CDBICompat/ImaDBI.pm @@ -44,7 +44,7 @@ __PACKAGE__->mk_classdata('_transform_sql_handlers' => $self->throw( "No relationship to JOIN from ${from_class} to ${to_class}" ) unless $rel_obj; my $join = $from_class->storage->sql_maker->_join_condition( - $from_class->result_source->resolve_condition( + $from_class->result_source_instance->resolve_condition( $rel_obj->{cond}, $to, $from) ); return $join; } @@ -91,7 +91,7 @@ sub sth_to_objects { my ($class, $sth) = @_; my @ret; while (my $row = $sth->fetchrow_hashref) { - push(@ret, $class->inflate_result($class->result_source, $row)); + push(@ret, $class->inflate_result($class->result_source_instance, $row)); } return @ret; } diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index 3166c98..cf96a37 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -15,7 +15,7 @@ sub storage { shift->schema_instance(@_)->storage; } sub resultset_instance { my $class = shift; - my $source = $class->result_source; + my $source = $class->result_source_instance; if ($source->result_class ne $class) { $source = $source->new($source); $source->result_class($class); diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 24c766d..b662a23 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -71,18 +71,6 @@ created, which calls C for the relationship. =cut -sub add_relationship { - shift->result_source->add_relationship(@_); -} - -sub relationships { - shift->result_source->relationships(@_); -} - -sub relationship_info { - shift->result_source->relationship_info(@_); -} - =head2 search_related My::Table->search_related('relname', $cond, $attrs); diff --git a/lib/DBIx/Class/ResultSourceInstance.pm b/lib/DBIx/Class/ResultSourceInstance.pm index 03fbe7d..ebe53c3 100644 --- a/lib/DBIx/Class/ResultSourceInstance.pm +++ b/lib/DBIx/Class/ResultSourceInstance.pm @@ -36,6 +36,18 @@ sub columns { sub set_primary_key { shift->result_source_instance->set_primary_key(@_); } sub primary_columns { shift->result_source_instance->primary_columns(@_); } +sub add_relationship { + shift->result_source_instance->add_relationship(@_); +} + +sub relationships { + shift->result_source_instance->relationships(@_); +} + +sub relationship_info { + shift->result_source_instance->relationship_info(@_); +} + sub result_source { shift->result_source_instance(@_); } 1; diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 33787aa..8a9f428 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -5,6 +5,8 @@ use warnings; use base qw/DBIx::Class/; +#__PACKAGE__->mk_group_accessors('simple' => 'result_source'); + =head1 NAME DBIx::Class::Row - Basic row methods diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index f948be3..35268d6 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -71,7 +71,7 @@ sub register_class { my %reg = %{$self->class_registrations}; $reg{$name} = $to_register; $self->class_registrations(\%reg); - $to_register->result_source->schema($self); + $to_register->result_source_instance->schema($self); } =head2 registered_classes @@ -109,7 +109,7 @@ Returns the result source object for the registered name sub source { my ($self, $class) = @_; - return $self->class_registrations->{$class}->result_source + return $self->class_registrations->{$class}->result_source_instance if $self->class_registrations->{$class}; } @@ -123,7 +123,7 @@ Returns the resultset for the registered name sub resultset { my ($self, $class) = @_; - return $self->class_registrations->{$class}->result_source->resultset; + return $self->class_registrations->{$class}->result_source_instance->resultset; } @@ -217,11 +217,11 @@ sub compose_connection { my $schema = $self->compose_namespace($target, $conn_class); $schema->storage($conn_class->storage); foreach my $class ($schema->registered_classes) { - my $source = $class->result_source; + my $source = $class->result_source_instance; $source = $source->new($source); $source->schema($schema); $source->result_class($class); - $class->mk_classdata(result_source => $source); + $class->mk_classdata(result_source_instance => $source); $class->mk_classdata(resultset_instance => $source->resultset); } return $schema; diff --git a/t/run/01core.tl b/t/run/01core.tl index 43f328b..ce41f16 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -114,7 +114,7 @@ $new->position(5); $new->insert_or_update; is( $schema->resultset("Track")->find(100)->position, 5, 'insert_or_update update ok'); -eval { $schema->resultset("Track")->load_components('DoesNotExist'); }; +eval { $schema->class("Track")->load_components('DoesNotExist'); }; ok $@, $@;