[Bast-commits] r9451 - in
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps:
lib/DBIx/Class/ResultSource lib/SQL/Translator/Parser/DBIx t
t/lib/ViewDeps/Result
amiri at dev.catalyst.perl.org
amiri at dev.catalyst.perl.org
Thu May 27 14:40:20 GMT 2010
Author: amiri
Date: 2010-05-27 15:40:20 +0100 (Thu, 27 May 2010)
New Revision: 9451
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/SQL/Translator/Parser/DBIx/Class.pm
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/Result/Bar.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm
Log:
view_sources sorter done? --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-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/DBIx/Class/ResultSource/View.pm 2010-05-27 14:40:20 UTC (rev 9451)
@@ -5,6 +5,8 @@
use DBIx::Class::ResultSet;
use SQL::Translator::Parser::DBIx::Class;
+use Data::Dumper::Concise;
+
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ResultSource/);
__PACKAGE__->mk_group_accessors(
@@ -151,9 +153,8 @@
my ( $self, @args ) = @_;
my $new = $self->next::method(@args);
$new->{deploy_depends_on}
- = { map { $_ => 1 } @{ ($new->{deploy_depends_on} || []) } };
- use Data::Dumper;
- print STDERR Dumper $new;
+ = { map { $_->result_source_instance->name => 1 } @{ $new->{deploy_depends_on}||[] } }
+ unless ref $new->{deploy_depends_on} eq 'HASH';
return $new;
}
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-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/lib/SQL/Translator/Parser/DBIx/Class.pm 2010-05-27 14:40:20 UTC (rev 9451)
@@ -11,12 +11,11 @@
use vars qw($DEBUG $VERSION @EXPORT_OK);
$VERSION = '1.10';
$DEBUG = 0 unless defined $DEBUG;
-
+use Data::Dumper;
use Exporter;
use SQL::Translator::Utils qw(debug normalize_name);
use Carp::Clan qw/^SQL::Translator|^DBIx::Class/;
use Scalar::Util ();
-
use base qw(Exporter);
@EXPORT_OK = qw(parse);
@@ -264,6 +263,7 @@
my $dependencies = {
map { $_ => _resolve_deps ($_, \%tables) } (keys %tables)
};
+
for my $table (sort
{
keys %{$dependencies->{$a} || {} } <=> keys %{ $dependencies->{$b} || {} }
@@ -292,14 +292,40 @@
}
my %views;
+ #my @view_sources =
+ #sort {
+ #(exists $a->deploy_depends_on->{$b->source_name} ? 1 : 0)
+ #<=>
+ #(exists $b->deploy_depends_on->{$a->source_name} ? 1 : 0)
+ #}
+ #map { $dbicschema->source($_) } (sort keys %view_monikers);
+
+ #my @view_sources =
+ #grep { $_->can('view_definition') } # make sure it's a view
+ #map { $dbicschema->source($_) } # have to get a source
+ #map { $tables{$_}{source}{source_name} } # have to get a sourcename
+ #sort {
+ #keys %{ $dependencies->{$a} || {} }
+ #<=>
+ #keys %{ $dependencies->{$b} || {} }
+ #||
+ #$a cmp $b
+ #}
+ #keys %$dependencies;
+
my @view_sources =
- sort {
- (exists $a->depends_on->{$b->source_name} ? 1 : 0)
- <=>
- (exists $b->depends_on->{$a->source_name} ? 1 : 0)
- }
- map { $dbicschema->source($_) } (sort keys %view_monikers);
+ sort {
+ keys %{ $dependencies->{$a} || {} }
+ <=>
+ keys %{ $dependencies->{$b} || {} }
+ ||
+ $a cmp $b
+ }
+ map { $dbicschema->source($_) } (sort keys %view_monikers);
+ print STDERR Dumper @view_sources;
+ print STDERR Dumper "Dependencies: ", $dependencies;
+
foreach my $source (@view_sources)
{
my $view_name = $source->name;
Modified: 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 2010-05-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/105view_deps.t 2010-05-27 14:40:20 UTC (rev 9451)
@@ -36,7 +36,8 @@
isa_ok( $schema->resultset('Bar')->result_source,
'DBIx::Class::ResultSource::View', 'Bar' );
-is( $bar_deps[0], 'mixin', 'which is reported to depend on mixin.' );
+is( $bar_deps[0], 'baz', 'which is reported to depend on baz...' );
+is( $bar_deps[1], 'mixin', 'and on mixin.' );
is( $foo_deps[0], undef, 'Foo has no dependencies...' );
isa_ok(
@@ -55,4 +56,10 @@
}
"...and you cannot use deploy_depends_on with that";
+diag("ViewDeps::Foo view definition: ", ViewDeps->source('Foo')->view_definition);
+diag("schema->rs(Bar) view definition: ", $schema->resultset('Bar')->result_source->view_definition);
+
+my $dir = "t/sql"; # tempdir(CLEANUP => 0);
+$schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir);
+
done_testing;
Modified: 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 2010-05-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Bar.pm 2010-05-27 14:40:20 UTC (rev 9451)
@@ -11,7 +11,7 @@
__PACKAGE__->table('bar');
__PACKAGE__->result_source_instance->deploy_depends_on(
- "ViewDeps::Result::Baz", "ViewDeps::Result::Mixin"
+["ViewDeps::Result::Baz", "ViewDeps::Result::Mixin"]
);
__PACKAGE__->add_columns(
Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm 2010-05-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Baz.pm 2010-05-27 14:40:20 UTC (rev 9451)
@@ -6,7 +6,7 @@
use warnings;
use base qw(DBIx::Class::Core);
-__PACKAGE__->table('bar');
+__PACKAGE__->table('baz');
__PACKAGE__->add_columns( id => { data_type => 'integer' } );
Modified: 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 2010-05-27 14:06:43 UTC (rev 9450)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/view-deps/t/lib/ViewDeps/Result/Foo.pm 2010-05-27 14:40:20 UTC (rev 9451)
@@ -8,6 +8,9 @@
__PACKAGE__->table_class(View);
__PACKAGE__->table('foo');
+
+__PACKAGE__->result_source_instance->view_definition("select * from just_a_table");
+
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
a => { data_type => 'integer', is_nullable => 1 }
@@ -18,4 +21,6 @@
__PACKAGE__->belongs_to( 'bar', 'ViewDeps::Result::Bar',
{ 'foreign.id' => 'self.a' } );
+
+
1;
More information about the Bast-commits
mailing list