fix for ^sqlite_ tables from chromatic
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / SQLite.pm
index ab8bfef..51530b4 100644 (file)
@@ -3,8 +3,9 @@ package DBIx::Class::Schema::Loader::DBI::SQLite;
 use strict;
 use warnings;
 use base qw/DBIx::Class::Schema::Loader::DBI/;
-use Class::C3;
+use Carp::Clan qw/^DBIx::Class/;
 use Text::Balanced qw( extract_bracketed );
+use Class::C3;
 
 =head1 NAME
 
@@ -76,12 +77,12 @@ sub _sqlite_parse_table {
         # Grab reference
         chomp $col;
 
-        if($col =~ /^(.*)\s+UNIQUE/) {
+        if($col =~ /^(.*)\s+UNIQUE/i) {
             my $colname = $1;
             $colname =~ s/\s+.*$//;
             push(@uniqs, [ "${colname}_unique" => [ lc $colname ] ]);
         }
-        elsif($col =~/^\s*UNIQUE\s*\(\s*(.*)\)/) {
+        elsif($col =~/^\s*UNIQUE\s*\(\s*(.*)\)/i) {
             my $cols = $1;
             $cols =~ s/\s+$//;
             my @cols = map { lc } split(/\s*,\s*/, $cols);
@@ -89,7 +90,7 @@ sub _sqlite_parse_table {
             push(@uniqs, [ $name => \@cols ]);
         }
 
-        next if $col !~ /^(.*)\s+REFERENCES\s+(\w+) (?: \s* \( (.*) \) )? /ix;
+        next if $col !~ /^(.*\S)\s+REFERENCES\s+(\w+) (?: \s* \( (.*) \) )? /ix;
 
         my ($cols, $f_table, $f_cols) = ($1, $2, $3);
 
@@ -105,7 +106,7 @@ sub _sqlite_parse_table {
         my $rcols;
         if($f_cols) {
             my @f_cols = map { s/\s*//g; lc $_ } split(/\s*,\s*/,$f_cols);
-            die "Mismatched column count in rel for $table => $f_table"
+            croak "Mismatched column count in rel for $table => $f_table"
               if @cols != @f_cols;
             $rcols = \@f_cols;
         }
@@ -146,6 +147,7 @@ sub _tables_list {
     my @tables;
     while ( my $row = $sth->fetchrow_hashref ) {
         next unless lc( $row->{type} ) eq 'table';
+        next if $row->{tbl_name} =~ /^sqlite_/;
         push @tables, $row->{tbl_name};
     }
     return @tables;