[Bast-commits] r4366 - in DBIx-Class/0.08/branches/replication_dedux: lib/SQL/Translator/Parser/DBIx t t/lib t/lib/DBICTest/Schema

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Thu May 8 22:43:17 BST 2008


Author: jnapiorkowski
Date: 2008-05-08 22:43:16 +0100 (Thu, 08 May 2008)
New Revision: 4366

Modified:
   DBIx-Class/0.08/branches/replication_dedux/lib/SQL/Translator/Parser/DBIx/Class.pm
   DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t
   DBIx-Class/0.08/branches/replication_dedux/t/86sqlt.t
   DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest.pm
   DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest/Schema/TreeLike.pm
   DBIx-Class/0.08/branches/replication_dedux/t/lib/sqlite.sql
Log:
more cleanup of the test suite so that we can run it against other databases.  fixed the problem with tests using self-referential constrainsts for dbs that have trouble handling that

Modified: DBIx-Class/0.08/branches/replication_dedux/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/lib/SQL/Translator/Parser/DBIx/Class.pm	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/lib/SQL/Translator/Parser/DBIx/Class.pm	2008-05-08 21:43:16 UTC (rev 4366)
@@ -128,7 +128,7 @@
             # Force the order of the referenced fields to be the same as
             # ->add_columns method.
             my $idx;
-            my %other_columns_idx = map {$_ => $idx++} $othertable->columns;
+            my %other_columns_idx = map {$_ => ++$idx } $othertable->columns;
             @refkeys = sort { $other_columns_idx{$a} cmp $other_columns_idx{$b} } @refkeys; 
             
             my @keys = map {$rel_info->{cond}->{$_} =~ /^\w+\.(\w+)$/} @cond;

Modified: DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/t/77prefetch.t	2008-05-08 21:43:16 UTC (rev 4366)
@@ -227,7 +227,7 @@
 $schema->storage->debug(1);
 
 my $tree_like =
-     $schema->resultset('TreeLike')->find(4,
+     $schema->resultset('TreeLike')->find(5,
        { join     => { parent => { parent => 'parent' } },
          prefetch => { parent => { parent => 'parent' } } });
 
@@ -244,21 +244,21 @@
 
 cmp_ok($queries, '==', 1, 'Only one query run');
 
-$tree_like = $schema->resultset('TreeLike')->search({'me.id' => 1});
+$tree_like = $schema->resultset('TreeLike')->search({'me.id' => 2});
 $tree_like = $tree_like->search_related('children')->search_related('children')->search_related('children')->first;
 is($tree_like->name, 'quux', 'Tree search_related ok');
 
 $tree_like = $schema->resultset('TreeLike')->search_related('children',
-    { 'children.id' => 2, 'children_2.id' => 3 },
+    { 'children.id' => 3, 'children_2.id' => 4 },
     { prefetch => { children => 'children' } }
   )->first;
 is(eval { $tree_like->children->first->children->first->name }, 'quux',
    'Tree search_related with prefetch ok');
 
 $tree_like = eval { $schema->resultset('TreeLike')->search(
-    { 'children.id' => 2, 'children_2.id' => 5 }, 
+    { 'children.id' => 3, 'children_2.id' => 6 }, 
     { join => [qw/children children/] }
-  )->search_related('children', { 'children_4.id' => 6 }, { prefetch => 'children' }
+  )->search_related('children', { 'children_4.id' => 7 }, { prefetch => 'children' }
   )->first->children->first; };
 is(eval { $tree_like->name }, 'fong', 'Tree with multiple has_many joins ok');
 

Modified: DBIx-Class/0.08/branches/replication_dedux/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/86sqlt.t	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/t/86sqlt.t	2008-05-08 21:43:16 UTC (rev 4366)
@@ -153,9 +153,9 @@
   treelike => [
     {
       'display' => 'treelike->treelike for parent',
-      'name' => 'treelike_fk_parent', 'index_name' => 'parent',
+      'name' => 'treelike_fk_parent_fk', 'index_name' => 'parent_fk',
       'selftable' => 'treelike', 'foreigntable' => 'treelike', 
-      'selfcols'  => ['parent'], 'foreigncols' => ['id'],
+      'selfcols'  => ['parent_fk'], 'foreigncols' => ['id'],
       on_delete => 'CASCADE', on_update => 'CASCADE', deferrable => 1,
     },
   ],
@@ -198,7 +198,7 @@
       'display' => 'forceforeign->artist',
       'name' => 'forceforeign_fk_artist', 'index_name' => 'artist',
       'selftable' => 'forceforeign', 'foreigntable' => 'artist', 
-      'selfcols'  => ['artist'], 'foreigncols' => ['artist_id'], 
+      'selfcols'  => ['artist'], 'foreigncols' => ['artistid'], 
       on_delete => '', on_update => '', deferrable => 1,
     },
   ],

Modified: DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest/Schema/TreeLike.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest/Schema/TreeLike.pm	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest/Schema/TreeLike.pm	2008-05-08 21:43:16 UTC (rev 4366)
@@ -6,15 +6,15 @@
 __PACKAGE__->table('treelike');
 __PACKAGE__->add_columns(
   'id' => { data_type => 'integer', is_auto_increment => 1 },
-  'parent' => { data_type => 'integer' },
+  'parent_fk' => { data_type => 'integer' , is_nullable=>1},
   'name' => { data_type => 'varchar',
     size      => 100,
  },
 );
 __PACKAGE__->set_primary_key(qw/id/);
 __PACKAGE__->belongs_to('parent', 'TreeLike',
-                          { 'foreign.id' => 'self.parent' });
-__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' });
+                          { 'foreign.id' => 'self.parent_fk' });
+__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent_fk' => 'self.id' });
 
 ## since this is a self referential table we need to do a post deploy hook and get
 ## some data in while constraints are off

Modified: DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest.pm
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest.pm	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/t/lib/DBICTest.pm	2008-05-08 21:43:16 UTC (rev 4366)
@@ -118,10 +118,7 @@
     my $args = shift || {};
 
     if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { 
-    	
-#$schema->create_ddl_dir([qw/MySQL/], $schema->VERSION, '.', undef, $args);
-$schema->deploy($args);    
-
+        $schema->deploy($args);    
     } else {
         open IN, "t/lib/sqlite.sql";
         my $sql;
@@ -230,18 +227,18 @@
         [ 1, 2 ],
         [ 1, 3 ],
     ]);
+    
+    $schema->populate('TreeLike', [
+        [ qw/id parent_fk name/ ],
+        [ 1, undef, 'root' ],        
+        [ 2, 1, 'foo'  ],
+        [ 3, 2, 'bar'  ],
+        [ 6, 2, 'blop' ],
+        [ 4, 3, 'baz'  ],
+        [ 5, 4, 'quux' ],
+        [ 7, 3, 'fong'  ],
+    ]);
 
- #   $schema->populate('TreeLike', [
- #       [ qw/id parent name/ ],
- #       [ 0, 0, 'root' ],
- #       [ 1, 0, 'foo'  ],
- #       [ 2, 1, 'bar'  ],
- #       [ 5, 1, 'blop' ],
- #       [ 3, 2, 'baz'  ],
- #       [ 4, 3, 'quux' ],
- #       [ 6, 2, 'fong'  ],
- #   ]);
-
     $schema->populate('Track', [
         [ qw/trackid cd  position title/ ],
         [ 4, 2, 1, "Stung with Success"],

Modified: DBIx-Class/0.08/branches/replication_dedux/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/branches/replication_dedux/t/lib/sqlite.sql	2008-05-08 20:26:01 UTC (rev 4365)
+++ DBIx-Class/0.08/branches/replication_dedux/t/lib/sqlite.sql	2008-05-08 21:43:16 UTC (rev 4366)
@@ -151,7 +151,7 @@
 --
 CREATE TABLE treelike (
   id INTEGER PRIMARY KEY NOT NULL,
-  parent integer NOT NULL,
+  parent_fk integer NULL,
   name varchar(100) NOT NULL
 );
 




More information about the Bast-commits mailing list