enable some formerly optional rel tests, add is_nullable extra test for SQLite
Rafael Kitover [Tue, 23 Feb 2010 15:31:51 +0000 (10:31 -0500)]
t/10sqlite_common.t
t/lib/dbixcsl_common_tests.pm

index 19dd1f4..2996738 100644 (file)
@@ -18,7 +18,7 @@ my $tester = dbixcsl_common_tests->new(
             q{
                 CREATE TABLE "extra_loader_test1" (
                     "id" NOT NULL PRIMARY KEY,
-                    "value" VARCHAR(100)
+                    "value" VARCHAR(100) NOT NULL
                 )
             },
             q{
@@ -45,17 +45,22 @@ my $tester = dbixcsl_common_tests->new(
             },
         ],
         drop  => [ qw/extra_loader_test1 extra_loader_test2 extra_loader_test3 extra_loader_test4 / ],
-        count => 5,
+        count => 7,
         run   => sub {
             my ($schema, $monikers, $classes) = @_;
 
             ok ((my $rs = $schema->resultset($monikers->{extra_loader_test1})),
                 'resultset for quoted table');
 
-            is_deeply [ $rs->result_source->columns ], [ qw/id value/ ],
+            ok ((my $source = $rs->result_source), 'source');
+
+            is_deeply [ $source->columns ], [ qw/id value/ ],
                 'retrieved quoted column names from quoted table';
 
-            ok ((my $source = $schema->source($monikers->{extra_loader_test4})),
+            is $source->column_info('value')->{is_nullable}, 0,
+                'is_nullable detection';
+
+            ok (($source = $schema->source($monikers->{extra_loader_test4})),
                 'verbose table');
 
             is_deeply [ $source->primary_columns ], [ qw/event_id person_id/ ],
index d26fb6c..e07ce36 100644 (file)
@@ -83,7 +83,7 @@ sub _custom_column_info {
 sub run_tests {
     my $self = shift;
 
-    plan tests => 156 + ($self->{extra}->{count} || 0);
+    plan tests => 157 + ($self->{extra}->{count} || 0);
 
     $self->create();
 
@@ -592,40 +592,33 @@ sub test_schema {
         is($obj27->loader_test29, undef, "Undef for missing one-to-one row");
 
         # test outer join for nullable referring columns:
-        SKIP: {
-          skip "unreliable column info from db driver",11 unless 
-            ($class32->column_info('rel2')->{is_nullable});
-
-          ok($class32->column_info('rel1')->{is_foreign_key}, 'Foreign key detected');
-          ok($class32->column_info('rel2')->{is_foreign_key}, 'Foreign key detected');
-          
-          my $obj32 = $rsobj32->find(1,{prefetch=>[qw/rel1 rel2/]});
-          my $obj34 = $rsobj34->find(
-            1,{prefetch=>[qw/loader_test33_id_rel1 loader_test33_id_rel2/]}
-          );
-          my $skip_outerjoin;
-          isa_ok($obj32,$class32) or $skip_outerjoin = 1;
-          isa_ok($obj34,$class34) or $skip_outerjoin = 1;
-
-          ok($class34->column_info('id')->{is_foreign_key}, 'Foreign key detected');
-          ok($class34->column_info('rel1')->{is_foreign_key}, 'Foreign key detected');
-          ok($class34->column_info('rel2')->{is_foreign_key}, 'Foreign key detected');
-
-          SKIP: {
-            skip "Pre-requisite test failed", 4 if $skip_outerjoin;
-            my $rs_rel31_one = $obj32->rel1;
-            my $rs_rel31_two = $obj32->rel2;
-            isa_ok($rs_rel31_one, $class31);
-            is($rs_rel31_two, undef);
-
-            my $rs_rel33_one = $obj34->loader_test33_id_rel1;
-            my $rs_rel33_two = $obj34->loader_test33_id_rel2;
-
-            isa_ok($rs_rel33_one,$class33);
-            is($rs_rel33_two, undef);
-
-          }
-        }
+        is $class32->column_info('rel2')->{is_nullable}, 1,
+          'is_nullable detection';
+
+        ok($class32->column_info('rel1')->{is_foreign_key}, 'Foreign key detected');
+        ok($class32->column_info('rel2')->{is_foreign_key}, 'Foreign key detected');
+        
+        my $obj32 = $rsobj32->find(1,{prefetch=>[qw/rel1 rel2/]});
+        my $obj34 = $rsobj34->find(
+          1,{prefetch=>[qw/loader_test33_id_rel1 loader_test33_id_rel2/]}
+        );
+        isa_ok($obj32,$class32);
+        isa_ok($obj34,$class34);
+
+        ok($class34->column_info('id')->{is_foreign_key}, 'Foreign key detected');
+        ok($class34->column_info('rel1')->{is_foreign_key}, 'Foreign key detected');
+        ok($class34->column_info('rel2')->{is_foreign_key}, 'Foreign key detected');
+
+        my $rs_rel31_one = $obj32->rel1;
+        my $rs_rel31_two = $obj32->rel2;
+        isa_ok($rs_rel31_one, $class31);
+        is($rs_rel31_two, undef);
+
+        my $rs_rel33_one = $obj34->loader_test33_id_rel1;
+        my $rs_rel33_two = $obj34->loader_test33_id_rel2;
+
+        isa_ok($rs_rel33_one,$class33);
+        is($rs_rel33_two, undef);
 
         # from Chisel's tests...
         my $moniker10 = $monikers->{loader_test10};