# Grab reference
chomp $col;
- if( $col =~ /^(.*)\s+REFERENCES\s+(\w+) (?: \s* \( (.*) \) )? /ix ) {
+ next if $col !~ /^(.*)\s+REFERENCES\s+(\w+) (?: \s* \( (.*) \) )? /ix;
- my ($cols, $f_table, $f_cols) = ($1, $2, $3);
+ my ($cols, $f_table, $f_cols) = ($1, $2, $3);
- if($cols =~ /^\(/) { # Table-level
- $cols =~ s/^\(\s*//;
- $cols =~ s/\s*\)$//;
- }
- else { # Inline
- $cols =~ s/\s+.*$//;
- }
+ if($cols =~ /^\(/) { # Table-level
+ $cols =~ s/^\(\s*//;
+ $cols =~ s/\s*\)$//;
+ }
+ else { # Inline
+ $cols =~ s/\s+.*$//;
+ }
- my $cond;
-
- if($f_cols) {
- my @cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$cols);
- my @f_cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$f_cols);
- die "Mismatched column count in rel for $table => $f_table"
- if @cols != @f_cols;
- $cond = {};
- for(my $i = 0 ; $i < @cols; $i++) {
- $cond->{$f_cols[$i]} = $cols[$i];
- }
- }
- else {
- $cond = $cols;
- }
+ my $cond;
- eval { $class->_loader_make_relations( $table, $f_table, $cond ) };
- warn qq/\# belongs_to_many failed "$@"\n\n/
- if $@ && $class->_loader_debug;
+ if($f_cols) {
+ my @cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$cols);
+ my @f_cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$f_cols);
+ die "Mismatched column count in rel for $table => $f_table"
+ if @cols != @f_cols;
+ $cond = {};
+ for(my $i = 0 ; $i < @cols; $i++) {
+ $cond->{$f_cols[$i]} = $cols[$i];
+ }
+ eval { $class->_loader_make_cond_rel( $table, $f_table, $cond ) };
}
+ else {
+ eval { $class->_loader_make_simple_rel( $table, $f_table, $cols ) };
+ }
+
+ warn qq/\# belongs_to_many failed "$@"\n\n/
+ if $@ && $class->_loader_debug;
}
}
}