From: Rafael Kitover Date: Thu, 6 Aug 2009 15:12:49 +0000 (+0000) Subject: add warning for custom resultsources through ->name(SCALARREF) on ->deploy X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39be4120d9aa8ae72ab5f2827cfa48fe28823b58;p=dbsrgits%2FDBIx-Class-Historic.git add warning for custom resultsources through ->name(SCALARREF) on ->deploy --- diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index 2740760..6e6d193 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -81,7 +81,14 @@ sub parse { { 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,8 +257,23 @@ sub parse { ) { $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) diff --git a/t/lib/DBICTest/Schema/CustomSql.pm b/t/lib/DBICTest/Schema/CustomSql.pm index d169d72..bdad8b8 100644 --- a/t/lib/DBICTest/Schema/CustomSql.pm +++ b/t/lib/DBICTest/Schema/CustomSql.pm @@ -12,4 +12,6 @@ __PACKAGE__->result_source_instance->name(\<schema->drop_table($_[1]) } + 1;