[Bast-commits] r7242 - in DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib: DBIx/Class/Manual SQL/Translator/Parser/DBIx

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Thu Aug 6 15:54:33 GMT 2009


Author: caelum
Date: 2009-08-06 15:54:33 +0000 (Thu, 06 Aug 2009)
New Revision: 7242

Modified:
   DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/DBIx/Class/Manual/Cookbook.pod
   DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
improve the ->name(REF) warning code

Modified: DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/DBIx/Class/Manual/Cookbook.pod
===================================================================
--- DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/DBIx/Class/Manual/Cookbook.pod	2009-08-06 15:12:49 UTC (rev 7241)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/DBIx/Class/Manual/Cookbook.pod	2009-08-06 15:54:33 UTC (rev 7242)
@@ -141,6 +141,13 @@
 
 Note that you cannot have bind parameters unless is_virtual is set to true.
 
+If you're using the old C<< $rsrc_instance->name(\'( SELECT ...') >> method for
+custom SQL, you are highly encouraged to update your code to use a virtual view
+as above. Otherwise add the following code so that on C<< ->deploy >> there is
+no attempt to create a table with that name:
+
+  sub sqlt_deploy_hook { $_[1]->schema->drop_table ($_[1]) }
+
 =head2 Using specific columns
 
 When you only want specific columns from a table, you can use

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 15:12:49 UTC (rev 7241)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm	2009-08-06 15:54:33 UTC (rev 7242)
@@ -82,13 +82,8 @@
         my $source = $dbicschema->source($moniker);
         my $table_name = $source->name;
 
-        if (ref $table_name) {
-          if (ref $table_name eq 'SCALAR') {
-            $table_name = $$table_name;
-          } else {
-            next;
-          }
-        }
+        # 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};
@@ -258,8 +253,9 @@
       $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) {
+      if ($schema->get_table($table) && $table =~ /SELECT \s+/ix) {
         warn <<'EOF';
+
 Custom SQL through ->name(\'( SELECT ...') is DEPRECATED, see the "Arbitrary
 SQL" entry in:
 
@@ -267,10 +263,6 @@
 
 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
       }
     }




More information about the Bast-commits mailing list