[Bast-commits] r5050 - in DBIx-Class/0.08/branches/views_support:
lib/DBIx/Class lib/SQL/Translator/Parser/DBIx t t/lib/DBICTest
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue Nov 4 17:45:07 GMT 2008
Author: ribasushi
Date: 2008-11-04 17:45:07 +0000 (Tue, 04 Nov 2008)
New Revision: 5050
Modified:
DBIx-Class/0.08/branches/views_support/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/views_support/lib/SQL/Translator/Parser/DBIx/Class.pm
DBIx-Class/0.08/branches/views_support/t/99dbic_sqlt_parser.t
DBIx-Class/0.08/branches/views_support/t/lib/DBICTest/Schema.pm
Log:
Patch salvaged by mst
Modified: DBIx-Class/0.08/branches/views_support/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/views_support/lib/DBIx/Class/ResultSource.pm 2008-11-04 17:43:15 UTC (rev 5049)
+++ DBIx-Class/0.08/branches/views_support/lib/DBIx/Class/ResultSource.pm 2008-11-04 17:45:07 UTC (rev 5050)
@@ -71,6 +71,18 @@
"_engine" => 'InnoDB',
});
+=cut
+
+sub is_virtual { 0 }
+
+=pod
+
+=head2 is_virtual
+
+Returns true if the resultsource is a virtual result source. This stub
+method returns false by default, see L<DBIx::Class::ResultSource::View>
+for more information.
+
=head2 add_columns
$table->add_columns(qw/col1 col2 col3/);
Modified: DBIx-Class/0.08/branches/views_support/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/views_support/lib/SQL/Translator/Parser/DBIx/Class.pm 2008-11-04 17:43:15 UTC (rev 5049)
+++ DBIx-Class/0.08/branches/views_support/lib/SQL/Translator/Parser/DBIx/Class.pm 2008-11-04 17:45:07 UTC (rev 5050)
@@ -65,8 +65,18 @@
@monikers = grep { $sources->{$_} } @monikers;
}
+ 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') ){
+ push(@view_monikers, $moniker);
+ }
+ }
- foreach my $moniker (sort @monikers)
+ foreach my $moniker (sort @table_monikers)
{
my $source = $dbicschema->source($moniker);
@@ -220,6 +230,26 @@
}
}
+ foreach my $moniker (sort @view_monikers)
+ {
+ my $source = $dbicschema->source($moniker);
+ # Skip custom query sources
+ next if ref($source->name);
+
+ # Its possible to have multiple DBIC source using same table
+ next if $seen_tables{$source->name}++;
+
+ my $view = $schema->add_view(
+ name => $source->name,
+ fields => [ $source->columns ],
+ $source->view_definition ? ( 'sql' => $source->view_definition ) : ()
+ );
+ if ($source->result_class->can('sqlt_deploy_hook')) {
+ $source->result_class->sqlt_deploy_hook($view);
+ }
+ }
+
+
if ($dbicschema->can('sqlt_deploy_hook')) {
$dbicschema->sqlt_deploy_hook($schema);
}
Modified: DBIx-Class/0.08/branches/views_support/t/99dbic_sqlt_parser.t
===================================================================
--- DBIx-Class/0.08/branches/views_support/t/99dbic_sqlt_parser.t 2008-11-04 17:43:15 UTC (rev 5049)
+++ DBIx-Class/0.08/branches/views_support/t/99dbic_sqlt_parser.t 2008-11-04 17:45:07 UTC (rev 5050)
@@ -19,6 +19,7 @@
foreach my $source ($schema->sources) {
my $table = $sqlt_schema->get_table($schema->source($source)->from);
+ next unless $table;
my $fk_count = scalar(grep { $_->type eq 'FOREIGN KEY' } $table->get_constraints);
my @indices = $table->get_indices;
@@ -33,6 +34,7 @@
foreach my $source ($schema->sources) {
my $table = $sqlt_schema->get_table($schema->source($source)->from);
+ next unless $table;
my $fk_count = scalar(grep { $_->type eq 'FOREIGN KEY' } $table->get_constraints);
my @indices = $table->get_indices;
@@ -47,6 +49,7 @@
foreach my $source ($schema->sources) {
my $table = $sqlt_schema->get_table($schema->source($source)->from);
+ next unless $table;
my @indices = $table->get_indices;
my $index_count = scalar(@indices);
Modified: DBIx-Class/0.08/branches/views_support/t/lib/DBICTest/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/views_support/t/lib/DBICTest/Schema.pm 2008-11-04 17:43:15 UTC (rev 5049)
+++ DBIx-Class/0.08/branches/views_support/t/lib/DBICTest/Schema.pm 2008-11-04 17:45:07 UTC (rev 5050)
@@ -17,6 +17,7 @@
#dummy
Track
Tag
+ Year2000CDs
/,
{ 'DBICTest::Schema' => [qw/
LinerNotes
More information about the Bast-commits
mailing list