Changed result_source to result_source_instance in strategic places
Matt S Trout [Mon, 16 Jan 2006 05:36:37 +0000 (05:36 +0000)]
lib/DBIx/Class/CDBICompat/ColumnCase.pm
lib/DBIx/Class/CDBICompat/ColumnGroups.pm
lib/DBIx/Class/CDBICompat/ImaDBI.pm
lib/DBIx/Class/DB.pm
lib/DBIx/Class/Relationship/Base.pm
lib/DBIx/Class/ResultSourceInstance.pm
lib/DBIx/Class/Row.pm
lib/DBIx/Class/Schema.pm
t/run/01core.tl

index d79104d..f0c3453 100644 (file)
@@ -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);
 }
 
index 77d6112..59c8348 100644 (file)
@@ -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) = @_;
index 144195e..7f645d5 100644 (file)
@@ -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;
 }
index 3166c98..cf96a37 100644 (file)
@@ -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);
index 24c766d..b662a23 100644 (file)
@@ -71,18 +71,6 @@ created, which calls C<create_related> 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);
index 03fbe7d..ebe53c3 100644 (file)
@@ -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;
index 33787aa..8a9f428 100644 (file)
@@ -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
index f948be3..35268d6 100644 (file)
@@ -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;
index 43f328b..ce41f16 100644 (file)
@@ -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 $@, $@;