use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ResultSource/);
__PACKAGE__->mk_group_accessors(
- 'simple' => qw(is_virtual view_definition)
+ '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
}
my %views;
- foreach my $moniker (sort @view_monikers)
+ 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($_) } @view_monikers;
+
+ foreach my $source (@view_sources)
{
- my $source = $dbicschema->source($moniker);
my $view_name = $source->name;
# FIXME - this isn't the right way to do it, but sqlt does not