Merge 'trunk' into 'view-deps'
[dbsrgits/DBIx-Class.git] / lib / SQL / Translator / Parser / DBIx / Class.pm
index ad5998d..3a5d918 100644 (file)
@@ -270,6 +270,7 @@ sub parse {
     my $dependencies = {
       map { $_ => _resolve_deps ($_, \%tables) } (keys %tables)
     };
+
     for my $table (sort
       {
         keys %{$dependencies->{$a} || {} } <=> keys %{ $dependencies->{$b} || {} }
@@ -298,9 +299,20 @@ EOW
     }
 
     my %views;
-    foreach my $moniker (sort keys %view_monikers)
+
+    my @view_sources =
+    sort {
+        keys %{ $a->deploy_depends_on || {} }
+        <=>
+        keys %{ $b->deploy_depends_on || {} }
+        ||
+        $a->source_name cmp $b->source_name
+    }
+    map { $dbicschema->source($_) }
+    keys %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
@@ -442,9 +454,15 @@ Limit the amount of parsed sources by supplying an explicit list of source names
 
 L<SQL::Translator>, L<DBIx::Class::Schema>
 
-=head1 AUTHORS
+=head1 AUTHOR
+
+Jess Robinson
+
+=head2 CONTRIBUTORS
 
-See L<DBIx::Class/CONTRIBUTORS>.
+Matt Trout
+Ash Berlin
+Amiri Barksdale
 
 =head1 LICENSE