From: Peter Rabbitson Date: Wed, 21 Jan 2009 13:51:21 +0000 (+0000) Subject: First stab at properly documenting the new sqlt_hook for resultsources X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d7d8459576fcc3f41845b40d755fc83a4b04c01;p=dbsrgits%2FDBIx-Class-Historic.git First stab at properly documenting the new sqlt_hook for resultsources --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index b86ab7a..216d71b 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -820,7 +820,7 @@ above is not fast enough for you, you can use a DBIx::Class to return values exactly as they come out of the data base with none of the convenience methods wrapped round them. -This is used like so:- +This is used like so: my $cursor = $rs->cursor while (my @vals = $cursor->next) { @@ -1167,7 +1167,9 @@ C Often you will want indexes on columns on your table to speed up searching. To do this, create a method called C in the relevant source -class: +class (refer to the advanced +L if you wish +to share a hook between multiple sources): package My::Schema::Artist; @@ -1201,9 +1203,11 @@ created: $sqlt_schema->drop_table('table_name'); } -You could also add views or procedures to the output using -L or -L. +You could also add views, procedures or triggers to the output using +L, +L or +L. + =head2 Schema versioning diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 4f62cba..cbba2a0 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -994,28 +994,6 @@ sub compare_relationship_keys { return $found; } -=head2 sqlt_deploy_hook - -=over 4 - -=item Arguments: $source, $sqlt_table - -=item Return value: undefined - -=back - -This is NOT a method of C. - -An optional sub which you can declare in your own Result class that will get -passed the L object when you deploy the schema -via L or L. - -This is useful to make L create non-unique indexes, -or set table options such as C. - -For an example of what you can do with this, see -L. - =head2 resolve_join =over 4 @@ -1409,9 +1387,36 @@ should not be used. It will be removed before 1.0. =cut -=head2 sqlt_deploy_hook($sqlt_table) +=head2 sqlt_deploy_hook + +=over 4 + +=item Arguments: $source, $sqlt_table -Triggers C. +=item Return value: undefined + +=back + +An optional sub which you can declare in your own Result class that will get +passed the L object when you deploy the schema +via L or L. + +This is useful to make L create non-unique indexes, or set +table options such as C. For an example of what you can do with +this, see +L. + +Note that sqlt_deploy_hook is called by +L, which in turn is called before +L. Therefore the hook can be used only to manipulate +the L object before it is turned into SQL fed to the +database. If you want to execute post-deploy statements which can not be generated +by L, the currently suggested method is to overload +L and use L. + +Starting from DBIC 0.08100 a simple hook is inherited by all result sources, which +invokes the method or coderef specified in L. You can still +overload this method like in older DBIC versions without any compatibility issues. =cut @@ -1422,6 +1427,14 @@ sub sqlt_deploy_hook { } } +=head2 sqlt_deploy_callback + +An attribute which contains the callback to trigger on C. +Defaults to C. Can be a code reference or the name +of a method in a result class. You would change the default value in case you +want to share a hook between several result sources, or if you want to use a +result source without a declared result class. + =head2 default_sqlt_deploy_hook($table) Delegates to a an optional C method on the C. @@ -1444,11 +1457,6 @@ sub default_sqlt_deploy_hook { } } -=head2 sqlt_deploy_callback - -An attribute which contains the callback to trigger on C. -Defaults to C. Can be a code reference or a method -name. =head1 AUTHORS diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index e58fbf2..02c48de 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -440,6 +440,13 @@ L or L. For an example of what you can do with this, see L. +Note that sqlt_deploy_hook is called by L, which in turn +is called before L. Therefore the hook can be used only to manipulate +the L object before it is turned into SQL fed to the +database. If you want to execute post-deploy statements which can not be generated +by L, the currently suggested method is to overload L +and use L. + =head1 METHODS =head2 connect