Tidy tests
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / lib / DBIx / Class / ResultSource / MultipleTableInheritance.pm
index 6e948f7..9dceab6 100644 (file)
@@ -146,14 +146,14 @@ method attach_additional_sources () {
     # have to use source name lookups rather than result class here
     # because we don't actually have a result class on the raw sources
     $table->add_relationship('parent', $parent->raw_source_name, \%pk_join);
-    $self->deploy_depends_on->{$parent->source_name} = 1;
+    $self->deploy_depends_on->{$parent->result_class} = 1;
   }
 
   foreach my $add (@{$self->additional_parents||[]}) {
     $table->add_relationship(
       'parent_'.$add->name, $add->source_name, \%pk_join
     );
-    $self->deploy_depends_on->{$add->source_name} = 1;
+    $self->deploy_depends_on->{$add->result_class} = 1;
   }
 
   # add every column that's actually a concrete part of us
@@ -276,7 +276,8 @@ BEGIN {
 
   *names_of = sub (@cols) { map $_->{name}, @cols };
 
-  *functionbody = sub ($name, $args, $body_parts) {
+  *function_body = sub {
+    my ($name,$args,$body_parts) = @_;
     my $arglist = join(
       ', ',
         map "_${\$_->{name}} ${\uc($_->{data_type})}",
@@ -293,6 +294,23 @@ BEGIN {
       $function$ LANGUAGE plpgsql;
     };
   };
+  #*function_body = sub ($name,$args,$body_parts) {
+    #my $arglist = join(
+      #', ',
+        #map "_${\$_->{name}} ${\uc($_->{data_type})}",
+          #@$args
+    #);
+    #my $body = join("\n", '', map "          $_;", @$body_parts);
+    #return strip tt q{
+      #CREATE OR REPLACE FUNCTION [% name %]
+        #([% arglist %])
+        #RETURNS VOID AS $function$
+        #BEGIN
+          #[%- body %]
+        #END;
+      #$function$ LANGUAGE plpgsql;
+    #};
+  #};
 }
 
 BEGIN {
@@ -368,7 +386,7 @@ method view_definition () {
   # NOTE: this assumes a single PK col called id with a sequence somewhere
   # but nothing else -should- so fixing this should make everything work
   my $insert_func =
-    functionbody
+    function_body
       $self->name.'_insert',
       \@body_cols,
       [
@@ -396,7 +414,7 @@ method view_definition () {
   # UPDATE function
 
   my $update_func =
-    functionbody
+    function_body
       $self->name.'_update',
       [ @pk_cols, @body_cols ],
       [ map $sqla->update(
@@ -409,7 +427,7 @@ method view_definition () {
   # DELETE function
 
   my $delete_func =
-    functionbody
+    function_body
       $self->name.'_delete',
       [ @pk_cols ],
       [ map $sqla->delete($_->name, $pk_where), @sources ];