X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FSQLite.pm;h=8a7a652e8039257968696b8e136432151cca2175;hb=a6900c9127d90a9bec26228a16f68a11cc13fb1d;hp=53313588ae3b7449e2f0e321c4d88a6a64c24e8d;hpb=0af7cacc7b7e906f0ef4b356fd9f4091d0bba01b;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index 5331358..8a7a652 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; use DBIx::Class::Schema::Loader::Table (); -our $VERSION = '0.07030'; +our $VERSION = '0.07039'; =head1 NAME @@ -147,8 +147,8 @@ where name = ? and tbl_name = ? EOF foreach my $fk (@rels) { - my $local_cols = '"?' . (join '"? \s* , \s* "?', @{ $fk->{local_columns} }) . '"?'; - my $remote_cols = '"?' . (join '"? \s* , \s* "?', @{ $fk->{remote_columns} || [] }) . '"?'; + my $local_cols = '"?' . (join '"? \s* , \s* "?', map quotemeta, @{ $fk->{local_columns} }) . '"?'; + my $remote_cols = '"?' . (join '"? \s* , \s* "?', map quotemeta, @{ $fk->{remote_columns} || [] }) . '"?'; my ($deferrable_clause) = $ddl =~ / foreign \s+ key \s* \( \s* $local_cols \s* \) \s* references \s* (?:\S+|".+?(?{attrs}{is_deferrable} = $deferrable_clause =~ /not/i ? 0 : 1; } else { - $fk->{attrs}{is_deferrable} = 0; + # check for inline constraint if 1 local column + if (@{ $fk->{local_columns} } == 1) { + my ($local_col) = @{ $fk->{local_columns} }; + my ($remote_col) = @{ $fk->{remote_columns} || [] }; + $remote_col ||= ''; + + my ($deferrable_clause) = $ddl =~ / + "?\Q$local_col\E"? \s* (?:\w+\s*)* (?: \( \s* \d\+ (?:\s*,\s*\d+)* \s* \) )? \s* + references \s+ (?:\S+|".+?(?{attrs}{is_deferrable} = $deferrable_clause =~ /not/i ? 0 : 1; + } + else { + $fk->{attrs}{is_deferrable} = 0; + } + } + else { + $fk->{attrs}{is_deferrable} = 0; + } } } @@ -225,6 +251,15 @@ sub _tables_list { return $self->_filter_tables(\@tables, $opts); } +sub _table_info_matches { + my ($self, $table, $info) = @_; + + my $table_schema = $table->schema; + $table_schema = 'main' if !defined $table_schema; + return $info->{TABLE_SCHEM} eq $table_schema + && $info->{TABLE_NAME} eq $table->name; +} + =head1 SEE ALSO L, L,