Working on sequences
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / lib / DBIx / Class / ResultSource / MultipleTableInheritance.pm
index 16a90af..ea14a3d 100644 (file)
@@ -103,6 +103,7 @@ method schema (@args) {
       @{$self->additional_parents||[]}
     ]);
   }
+  use Devel::Dwarn; use 5.012; say Dwarn $ret;
   return $ret;
 }
 
@@ -162,13 +163,18 @@ method attach_additional_sources () {
   );
   $table->set_primary_key($self->primary_columns);
   
-  # Attempting to re-add sequence here -- AKB
+  ## Attempting to re-add sequence here -- AKB
   for my $pk ( $self->primary_columns ) {
-    $table->columns_info->{$pk}->{sequence} =
-      $self->set_sequence( $table->name, $self->primary_columns )
-      unless grep {
-      $table->columns_info->{$_}->{originally_defined_in} ne $self->name
-      } keys %{ $table->columns_info };
+    if ($parent) {
+
+#use 5.012; use Devel::Dwarn; say Dwarn $schema->source($table->_relationships->{parent}->{class}) if $table->_relationships->{parent}->{class};
+      $table->columns_info->{$pk}->{sequence} =
+        $self->set_sequence(
+        $schema->source( $table->_relationships->{parent}->{class} )->name,
+        $self->primary_columns )
+        if $table->columns_info->{$pk}->{originally_defined_in} ne $self->name
+          && $table->_relationships->{parent}->{class};
+    }
   }
 
   # we need to copy our rels to the raw object as well