fix sqlite FKs (broken during multi-fk work)
Brandon Black [Fri, 27 Jan 2006 14:47:11 +0000 (14:47 +0000)]
lib/DBIx/Class/Schema/Loader/SQLite.pm

index bf76503..5aa7d11 100644 (file)
@@ -75,10 +75,19 @@ SELECT sql FROM sqlite_master WHERE tbl_name = ?
             $col =~ s/^\s+//gs;
 
             # Grab reference
-            if ( $col =~ /^\((.*)\)\s+REFERENCES\s+(\w+)\s*\((.*)\)/i ) {
+            if( $col =~ /^(.*)\s+REFERENCES\s+(\w+)\s*\((.*)\)/i ) {
                 chomp $col;
 
                 my ($cols, $f_table, $f_cols) = ($1, $2, $3);
+
+                if($cols =~ /^\(/) { # Table-level
+                    $cols =~ s/^\(\s*//;
+                    $cols =~ s/\s*\)$//;
+                }
+                else {               # Inline
+                    $cols =~ s/\s+.*$//;
+                }
+
                 my @cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$cols);
                 my @f_cols = map { s/\s*//g; $_ } split(/\s*,\s*/,$f_cols);