[Bast-commits] r7241 - in DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref: lib/SQL/Translator/Parser/DBIx t/lib/DBICTest/Schema

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Thu Aug 6 15:12:49 GMT 2009


Author: caelum
Date: 2009-08-06 15:12:49 +0000 (Thu, 06 Aug 2009)
New Revision: 7241

Modified:
   DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm
   DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/t/lib/DBICTest/Schema/CustomSql.pm
Log:
add warning for custom resultsources through ->name(SCALARREF) on ->deploy

Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm	2009-08-06 13:48:54 UTC (rev 7240)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm	2009-08-06 15:12:49 UTC (rev 7241)
@@ -81,8 +81,15 @@
     {
         my $source = $dbicschema->source($moniker);
         my $table_name = $source->name;
-        $table_name = $$table_name if ref $table_name eq 'SCALAR';  #sqlt currently does not do quoting right anyway
 
+        if (ref $table_name) {
+          if (ref $table_name eq 'SCALAR') {
+            $table_name = $$table_name;
+          } else {
+            next;
+          }
+        }
+
         # Its possible to have multiple DBIC sources using the same table
         next if $tables{$table_name};
 
@@ -250,9 +257,24 @@
     ) {
       $schema->add_table ($tables{$table}{object});
       $tables{$table}{source} -> _invoke_sqlt_deploy_hook( $tables{$table}{object} );
+
+      if ($schema->get_table($table) && $table =~ /\( \s* SELECT \s+/x) {
+        warn <<'EOF';
+Custom SQL through ->name(\'( SELECT ...') is DEPRECATED, see the "Arbitrary
+SQL" entry in:
+
+  perldoc DBIx::Class::Manual::Cookbook
+
+for the current method of doing this.
+
+To exclude this Result class from ->deploy, add the following to it:
+
+  sub sqlt_deploy_hook { $_[1]->schema->drop_table ($_[1]) }
+
+EOF
+      }
     }
 
-
     my %views;
     foreach my $moniker (sort @view_monikers)
     {

Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/t/lib/DBICTest/Schema/CustomSql.pm
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/t/lib/DBICTest/Schema/CustomSql.pm	2009-08-06 13:48:54 UTC (rev 7240)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/t/lib/DBICTest/Schema/CustomSql.pm	2009-08-06 15:12:49 UTC (rev 7241)
@@ -12,4 +12,6 @@
   WHERE cd.year = ?)
 SQL
 
+sub sqlt_deploy_hook { $_[1]->schema->drop_table($_[1]) }
+
 1;




More information about the Bast-commits mailing list