[Bast-commits] r7905 - in DBIx-Class/0.08/branches/view_rels: . lib/SQL/Translator/Parser/DBIx

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Nov 15 12:29:23 GMT 2009


Author: ribasushi
Date: 2009-11-15 12:29:23 +0000 (Sun, 15 Nov 2009)
New Revision: 7905

Modified:
   DBIx-Class/0.08/branches/view_rels/Changes
   DBIx-Class/0.08/branches/view_rels/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
FK constraints towards a view don't quite work

Modified: DBIx-Class/0.08/branches/view_rels/Changes
===================================================================
--- DBIx-Class/0.08/branches/view_rels/Changes	2009-11-15 12:26:23 UTC (rev 7904)
+++ DBIx-Class/0.08/branches/view_rels/Changes	2009-11-15 12:29:23 UTC (rev 7905)
@@ -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)

Modified: DBIx-Class/0.08/branches/view_rels/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/view_rels/lib/SQL/Translator/Parser/DBIx/Class.pm	2009-11-15 12:26:23 UTC (rev 7904)
+++ DBIx-Class/0.08/branches/view_rels/lib/SQL/Translator/Parser/DBIx/Class.pm	2009-11-15 12:29:23 UTC (rev 7905)
@@ -86,7 +86,7 @@
         # 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 @@
             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 @@
                 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 @@
                   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),




More information about the Bast-commits mailing list