From: Peter Rabbitson Date: Sun, 15 Nov 2009 12:29:23 +0000 (+0000) Subject: FK constraints towards a view don't quite work X-Git-Tag: v0.08116~140^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=e3d5a54703819b831dc177f60ded50328629973b FK constraints towards a view don't quite work --- diff --git a/Changes b/Changes index 0f2dead..470d3db 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for DBIx::Class + - Do not attempt to deploy FK constraints pointing to a View + 0.08114 2009-11-14 17:45:00 (UTC) - Preliminary support for MSSQL via DBD::ADO - Fix botched 0.08113 release (invalid tarball) diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index b570d60..bb40c91 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -86,7 +86,7 @@ sub parse { # support quoting properly to be signaled about this $table_name = $$table_name if ref $table_name eq 'SCALAR'; - # Its possible to have multiple DBIC sources using the same table + # It's possible to have multiple DBIC sources using the same table next if $tables{$table_name}; $tables{$table_name}{source} = $source; @@ -141,6 +141,7 @@ sub parse { next unless ref $rel_info->{cond} eq 'HASH'; my $othertable = $source->related_source($rel); + next if $othertable->isa('DBIx::Class::ResultSource::View'); # can't define constraints referencing a view my $rel_table = $othertable->name; # FIXME - this isn't the right way to do it, but sqlt does not @@ -200,7 +201,7 @@ sub parse { next unless $fk_constraint; # Make sure we dont create the same foreign key constraint twice - my $key_test = join("\x00", @keys); + my $key_test = join("\x00", sort @keys); next if $created_FK_rels{$rel_table}->{$key_test}; if (scalar(@keys)) { @@ -214,7 +215,6 @@ sub parse { if (! $is_deferrable and $rel_table ne $table_name) { $tables{$table_name}{foreign_table_deps}{$rel_table}++; } - $table->add_constraint( type => 'foreign_key', name => join('_', $table_name, 'fk', @keys),