[Bast-commits] r9411 - in
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps:
lib/DBIx lib/DBIx/Class/ResultSource
lib/SQL/Translator/Parser/DBIx t t/lib t/lib/ViewDeps
t/lib/ViewDeps/Result
amiri at dev.catalyst.perl.org
amiri at dev.catalyst.perl.org
Thu May 20 22:09:45 GMT 2010
Author: amiri
Date: 2010-05-20 23:09:45 +0100 (Thu, 20 May 2010)
New Revision: 9411
Added:
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/JustATable.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm
Modified:
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
Add test files and test for vie
Add test files and lib for new view_deps functionality. AKB
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm 2010-05-20 18:09:52 UTC (rev 9410)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -11,12 +11,6 @@
'simple' => qw(is_virtual view_definition depends_on)
);
-sub new {
- my $new = shift->next::method(@_);
- $new->{depends_on} = { %{$new->{depends_on}||{}} };
- return $new;
-}
-
=head1 NAME
DBIx::Class::ResultSource::View - ResultSource object representing a view
@@ -136,9 +130,21 @@
An SQL query for your view. Will not be translated across database
syntaxes.
-
=head1 OVERRIDDEN METHODS
+=head2 new
+
+The constructor. This is a private method, as only other DBIC modules
+should call this. See L<DBIx::Class::ResultSource::MultipleTableInheritance>.
+
+=cut
+
+sub new {
+ my $new = shift->next::method(@_);
+ $new->{depends_on} = { %{$new->{depends_on}||{}} };
+ return $new;
+}
+
=head2 from
Returns the FROM entry for the table (i.e. the view name)
@@ -152,6 +158,17 @@
return $self->name;
}
+=head1 PRIVATE METHODS
+
+=head2 depends_on
+
+An internal method for the construction of a hashref of the view's
+superclasses, e.g., the sources that comprise it.
+
+See L<DBIx::Class::ResultSource::MultipleTableInheritance>.
+
+=cut
+
1;
=head1 AUTHORS
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class.pm 2010-05-20 18:09:52 UTC (rev 9410)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -222,6 +222,8 @@
aherzog: Adam Herzog <adam at herzogdesigns.com>
+amiri: Amiri Barksdale <amiri at metalabel.com>
+
amoore: Andrew Moore <amoore at cpan.org>
andyg: Andy Grundman <andy at hybridized.org>
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/SQL/Translator/Parser/DBIx/Class.pm 2010-05-20 18:09:52 UTC (rev 9410)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/SQL/Translator/Parser/DBIx/Class.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -298,7 +298,7 @@
<=>
(exists $b->depends_on->{$a->source_name} ? 1 : 0)
}
- map { $dbicschema->source($_) } (sort keys %@view_monikers);
+ map { $dbicschema->source($_) } (sort keys %view_monikers);
foreach my $source (@view_sources)
{
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use Devel::Dwarn;
+use ViewDeps;
+
+BEGIN {
+ use_ok('DBIx::Class::ResultSource::View');
+}
+
+my $view = DBIx::Class::ResultSource::View->new( { name => 'Upsilon' } );
+isa_ok( $view, 'DBIx::Class::ResultSource' );
+isa_ok( $view, 'DBIx::Class' );
+
+can_ok( $view, $_ ) for qw/new from depends_on/;
+
+diag( map {"$_\n"} @{ mro::get_linear_isa($view) } );
+#diag( DwarnS $view);
+
+my $schema = ViewDeps->connect;
+ok($schema);
+
+#diag(DwarnS $schema);
+
+#diag(DwarnS $schema->resultset('Bar')->result_source->depends_on);
+diag keys %{$schema->resultset('Bar')->result_source->depends_on};
+my @dependencies = keys %{$schema->resultset('Bar')->result_source->depends_on};
+is($dependencies[0], 'mixin');
+
+done_testing;
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,32 @@
+package # hide from PAUSE
+ ViewDeps::Result::Bar;
+
+use strict;
+use warnings;
+use parent qw(ViewDeps::Result::Foo);
+
+require ViewDeps::Result::Mixin;
+
+__PACKAGE__->table('bar');
+
+__PACKAGE__->result_source_instance->depends_on(
+ { ViewDeps::Result::Mixin->result_source_instance->name => 1 }
+);
+
+__PACKAGE__->add_columns(
+ b => { data_type => 'integer' }
+);
+
+__PACKAGE__->belongs_to(
+ 'b_thang',
+ 'ViewDeps::Result::JustATable',
+ { 'foreign.id' => 'self.b' },
+);
+
+__PACKAGE__->has_many(
+ 'foos',
+ 'ViewDeps::Result::Foo',
+ { 'foreign.a' => 'self.id' }
+);
+
+1;
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,26 @@
+package # hide from PAUSE
+ ViewDeps::Result::Foo;
+
+use strict;
+use warnings;
+use parent qw(DBIx::Class::Core);
+use aliased 'DBIx::Class::ResultSource::View';
+
+__PACKAGE__->table_class(View);
+
+__PACKAGE__->table('foo');
+
+__PACKAGE__->add_columns(
+ id => { data_type => 'integer', is_auto_increment => 1 },
+ a => { data_type => 'integer', is_nullable => 1 }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+__PACKAGE__->belongs_to(
+ 'bar',
+ 'ViewDeps::Result::Bar',
+ { 'foreign.id' => 'self.a' }
+);
+
+1;
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/JustATable.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/JustATable.pm (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/JustATable.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,22 @@
+package # hide from PAUSE
+ ViewDeps::Result::JustATable;
+
+use base qw(DBIx::Class::Core);
+
+__PACKAGE__->table('just_a_table');
+
+__PACKAGE__->add_columns(
+ id => { data_type => 'integer', is_auto_increment => 1 },
+ name => { data_type => 'varchar', size => 255 }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+__PACKAGE__->has_many(
+ 'bars',
+ 'ViewDeps::Result::Bar',
+ { 'foreign.b' => 'self.id' }
+);
+
+
+1;
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Mixin.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,19 @@
+package # hide from PAUSE
+ ViewDeps::Result::Mixin;
+
+use strict;
+use warnings;
+use parent qw(DBIx::Class::Core);
+
+__PACKAGE__->table('mixin');
+
+__PACKAGE__->add_columns(
+ id => {
+ data_type => 'integer', is_auto_increment => 1, sequence => 'foo_id_seq'
+ },
+ words => { data_type => 'text' }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
Added: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps.pm (rev 0)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps.pm 2010-05-20 22:09:45 UTC (rev 9411)
@@ -0,0 +1,17 @@
+package # hide from PAUSE
+ ViewDeps;
+
+use strict;
+use warnings;
+use parent qw(DBIx::Class::Schema);
+use aliased 'DBIx::Class::ResultSource::View' => 'View';
+
+__PACKAGE__->load_namespaces;
+
+#for my $p (__PACKAGE__) {
+ #$p->load_namespaces;
+ #$_->attach_additional_sources
+ #for grep $_->isa(View), map $p->source($_), $p->sources;
+#}
+
+1;
More information about the Bast-commits
mailing list