[Bast-commits] r7265 - in
DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib:
DBIx/Class/Manual SQL/Translator/Parser/DBIx
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sat Aug 8 22:23:24 GMT 2009
Author: ribasushi
Date: 2009-08-08 22:23:24 +0000 (Sat, 08 Aug 2009)
New Revision: 7265
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:
Clarify POD and cleanup the ->name-hack warning
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-08 15:51:23 UTC (rev 7264)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/DBIx/Class/Manual/Cookbook.pod 2009-08-08 22:23:24 UTC (rev 7265)
@@ -103,8 +103,9 @@
be optimized for your database in a special way, but you still want to
get the results as a L<DBIx::Class::ResultSet>.
-The recommended way to accomplish this is by defining a separate
-L<ResultSource::View|DBIx::Class::ResultSource::View> for your query.
+This is accomplished by defining a
+L<ResultSource::View|DBIx::Class::ResultSource::View> for your query,
+almost like you would define a regular ResultSource.
package My::Schema::Result::UserFriendsComplex;
use strict;
@@ -116,7 +117,9 @@
# ->table, ->add_columns, etc.
+ # do not attempt to deploy() this view
__PACKAGE__->result_source_instance->is_virtual(1);
+
__PACKAGE__->result_source_instance->view_definition(q[
SELECT u.* FROM user u
INNER JOIN user_friends f ON u.id = f.user_id
@@ -141,13 +144,21 @@
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:
+=over
+=item * NOTE
+
+If you're using the old deprecated C<< $rsrc_instance->name(\'( SELECT ...') >>
+method for custom SQL execution, you are highly encouraged to update your code
+to use a virtual view as above. If you do not want to change your code, and just
+want to suppress the deprecation warning when you call
+L<DBIx::Class::Schema/deploy>, add this line to your source definition, so that
+C<deploy> will exclude this "table":
+
sub sqlt_deploy_hook { $_[1]->schema->drop_table ($_[1]) }
+=back
+
=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-08 15:51:23 UTC (rev 7264)
+++ DBIx-Class/0.08/branches/_abandoned_but_possibly_useful/table_name_ref/lib/SQL/Translator/Parser/DBIx/Class.pm 2009-08-08 22:23:24 UTC (rev 7265)
@@ -253,17 +253,19 @@
$schema->add_table ($tables{$table}{object});
$tables{$table}{source} -> _invoke_sqlt_deploy_hook( $tables{$table}{object} );
- if ($schema->get_table($table) && $table =~ /SELECT \s+/ix) {
- warn <<'EOF';
+ # 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, see the "Arbitrary
-SQL" entry in:
+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
- perldoc DBIx::Class::Manual::Cookbook
+EOW
-for the current method of doing this.
-
-EOF
+ # remove the table as there is no way someone might want to
+ # actually deploy this
+ $schema->drop_table ($table);
}
}
More information about the Bast-commits
mailing list