From: Brandon Black Date: Fri, 27 Jan 2006 14:47:11 +0000 (+0000) Subject: fix sqlite FKs (broken during multi-fk work) X-Git-Tag: 0.03000~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=132694df167594a69713edd5f472765191215bfd;p=dbsrgits%2FDBIx-Class-Schema-Loader.git fix sqlite FKs (broken during multi-fk work) --- diff --git a/lib/DBIx/Class/Schema/Loader/SQLite.pm b/lib/DBIx/Class/Schema/Loader/SQLite.pm index bf76503..5aa7d11 100644 --- a/lib/DBIx/Class/Schema/Loader/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/SQLite.pm @@ -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);