Move and simplify a chunk of parser code
[dbsrgits/DBIx-Class.git] / lib / SQL / Translator / Parser / DBIx / Class.pm
index 4fd03f2..5a846c0 100644 (file)
@@ -186,9 +186,6 @@ sub parse {
             # support quoting properly to be signaled about this
             $rel_table = $$rel_table if ref $rel_table eq 'SCALAR';
 
-            my $reverse_rels = $source->reverse_relationship_info($rel);
-            my ($otherrelname, $otherrelationship) = each %{$reverse_rels};
-
             # Force the order of @cond to match the order of ->add_columns
             my $idx;
             my %other_columns_idx = map {'foreign.'.$_ => ++$idx } $relsource->columns;
@@ -217,6 +214,8 @@ sub parse {
                 $fk_constraint = not $source->_compare_relationship_keys(\@keys, \@primary);
             }
 
+            my ($otherrelname, $otherrelationship) = %{ $source->reverse_relationship_info($rel) };
+
             my $cascade;
             for my $c (qw/delete update/) {
                 if (exists $rel_info->{attrs}{"on_$c"}) {