Add view test.
Jess Robinson [Thu, 19 Feb 2009 22:04:06 +0000 (22:04 +0000)]
Only check is_virtual on view sources

lib/SQL/Translator/Parser/DBIx/Class.pm
t/104view.t [new file with mode: 0644]
t/lib/DBICTest/Schema/Year2000CDs.pm

index 835edbb..bff7ddc 100644 (file)
@@ -69,10 +69,10 @@ sub parse {
     my(@table_monikers, @view_monikers);
     for my $moniker (@monikers){
       my $source = $dbicschema->source($moniker);
-      next if $source->is_virtual;
        if ( $source->isa('DBIx::Class::ResultSource::Table') ) {
          push(@table_monikers, $moniker);
       } elsif( $source->isa('DBIx::Class::ResultSource::View') ){
+          next if $source->is_virtual;
          push(@view_monikers, $moniker);
       }
     }
diff --git a/t/104view.t b/t/104view.t
new file mode 100644 (file)
index 0000000..f800af4
--- /dev/null
@@ -0,0 +1,19 @@
+use strict;
+use warnings;  
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+plan tests => 1;
+
+my $cds_rs = $schema->resultset('CD')->search( { year => 2000 });
+my $year2kcds_rs = $schema->resultset('Year2000CDs');
+
+is($cds_rs->count, $year2kcds_rs->count, 'View Year2000CDs sees all CDs in year 2000');
+
+
+
index be91397..5293c69 100644 (file)
@@ -1,5 +1,6 @@
 package # hide from PAUSE 
     DBICTest::Schema::Year2000CDs;
+## Used in 104view.t
 
 use base 'DBIx::Class::Core';
 use DBIx::Class::ResultSource::View;