From: Brendan Byrd Date: Mon, 10 Dec 2012 22:10:26 +0000 (-0500) Subject: Fill gaps in documentation: alias ($rs attr), table_alias, result_class X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8893ffd05dee05ba32bb64b4ce16ca805145aeb3;p=dbsrgits%2FDBIx-Class-Historic.git Fill gaps in documentation: alias ($rs attr), table_alias, result_class --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 664f745..70ff1fb 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -4198,6 +4198,37 @@ behavior may or may not survive the 0.09 transition. =back +=head2 alias + +=over 4 + +=item Value: $source_alias + +=back + +Sets the source alias for the query. Normally, this defaults to C, but +nested search queries (sub-SELECTs) might need specific aliases set to +reference inner queries. For example: + + my $q = $rs + ->related_resultset('CDs') + ->related_resultset('Tracks') + ->search({ + 'track.id' => { -ident => 'none_search.id' }, + }) + ->as_query; + + my $ids = $self->search({ + -not_exists => $q, + }, { + alias => 'none_search', + group_by => 'none_search.id', + })->get_column('id')->as_query; + + $self->search({ id => { -in => $ids } }) + +This attribute is directly tied to L. + =head2 page =over 4 diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index c773e19..a4d3169 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -961,6 +961,32 @@ sub _invoke_sqlt_deploy_hook { } } +=head2 result_class + +=over 4 + +=item Arguments: $classname + +=item Return Value: $classname + +=back + + use My::Schema::ResultClass::Inflator; + ... + + use My::Schema::Artist; + ... + __PACKAGE__->result_class('My::Schema::ResultClass::Inflator'); + +Set the default result class for this source. You can use this to create +and use your own result inflator. See L +for more details. + +Please note that setting this to something like +L will make every result unblessed +and make life more difficult. Inflators like those are better suited to +temporary usage via L. + =head2 resultset =over 4 diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index deb198a..fe72d4d 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -104,6 +104,14 @@ sub table { return $class->result_source_instance->name; } +=head2 table_class + + __PACKAGE__->table_class('DBIx::Class::ResultSource::Table'); + +Gets or sets the table class used for construction and validation. + +=cut + =head2 has_column if ($obj->has_column($col)) { ... }