Clarify POD and cleanup the ->name-hack warning
[dbsrgits/DBIx-Class.git] / lib / SQL / Translator / Parser / DBIx / Class.pm
index 85a1028..de7c948 100644 (file)
@@ -82,8 +82,8 @@ sub parse {
         my $source = $dbicschema->source($moniker);
         my $table_name = $source->name;
 
-        # Skip custom query sources
-        next if ref $table_name;
+        # sqlt currently does not do quoting right anyway
+        $table_name = $$table_name if ref $table_name eq 'SCALAR';
 
         # Its possible to have multiple DBIC sources using the same table
         next if $tables{$table_name};
@@ -141,6 +141,7 @@ sub parse {
 
             my $othertable = $source->related_source($rel);
             my $rel_table = $othertable->name;
+            $rel_table = $$rel_table if ref $rel_table eq 'SCALAR';  #sqlt currently does not do quoting right anyway
 
             my $reverse_rels = $source->reverse_relationship_info($rel);
             my ($otherrelname, $otherrelationship) = each %{$reverse_rels};
@@ -251,14 +252,29 @@ sub parse {
     ) {
       $schema->add_table ($tables{$table}{object});
       $tables{$table}{source} -> _invoke_sqlt_deploy_hook( $tables{$table}{object} );
-    }
 
+      # the hook might have already removed the table
+      if ($schema->get_table($table) && $table =~ /^ \s* \( \s* SELECT \s+/ix) {
+        warn <<'EOW';
+
+Custom SQL through ->name(\'( SELECT ...') is DEPRECATED, for more details see
+"Arbitrary SQL through a custom ResultSource" in DBIx::Class::Manual::Cookbook
+or http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod
+
+EOW
+
+        # remove the table as there is no way someone might want to
+        # actually deploy this
+        $schema->drop_table ($table);
+      }
+    }
 
     my %views;
     foreach my $moniker (sort @view_monikers)
     {
         my $source = $dbicschema->source($moniker);
         my $view_name = $source->name;
+        $view_name = $$view_name if ref $view_name eq 'SCALAR';  #sqlt currently does not do quoting right anyway
 
         # Skip custom query sources
         next if ref $view_name;
@@ -353,7 +369,7 @@ This class requires L<SQL::Translator> installed to work.
 C<SQL::Translator::Parser::DBIx::Class> reads a DBIx::Class schema,
 interrogates the columns, and stuffs it all in an $sqlt_schema object.
 
-It's primary use is in deploying database layouts described as a set
+Its primary use is in deploying database layouts described as a set
 of L<DBIx::Class> classes, to a database. To do this, see
 L<DBIx::Class::Schema/deploy>.