X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;h=f75f393a2cde87f3017b683e91fbc5d57789d45f;hb=d63c9e64;hp=2d54ec0a39d31027f6dcc5f94904b226a3ef770f;hpb=e084cb2bccea6e55372bb772ab02b7c9804542a1;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 2d54ec0..f75f393 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -77,7 +77,7 @@ More specifically, the L base class pulls in the L component, which defines the L method. When called, C creates and stores an instance of -L. Luckily, to use tables as result +L. Luckily, to use tables as result sources, you don't need to remember any of this. Result sources representing select queries, or views, can also be @@ -86,7 +86,8 @@ created, see L for full details. =head2 Finding result source objects As mentioned above, a result source instance is created and stored for -you when you define a L. +you when you define a +L. You can retrieve the result source at runtime in the following ways: @@ -108,7 +109,13 @@ You can retrieve the result source at runtime in the following ways: =head1 METHODS -=pod +=head2 new + + $class->new(); + + $class->new({attribute_name => value}); + +Creates a new ResultSource object. Not normally called directly by end users. =cut @@ -582,7 +589,7 @@ sub remove_column { shift->remove_columns(@_); } # DO NOT CHANGE THIS TO GLOB Defines one or more columns as primary key for this source. Must be called after L. -Additionally, defines a L +Additionally, defines a L named C. Note: you normally do want to define a primary key on your sources @@ -1180,6 +1187,17 @@ clause contents. sub from { die 'Virtual method!' } +=head2 source_info + +Stores a hashref of per-source metadata. No specific key names +have yet been standardized, the examples below are purely hypothetical +and don't actually accomplish anything on their own: + + __PACKAGE__->source_info({ + "_tablespace" => 'fast_disk_array_3', + "_engine" => 'InnoDB', + }); + =head2 schema =over 4 @@ -1331,7 +1349,6 @@ sub add_relationship { my %rels = %{ $self->_relationships }; $rels{$rel} = { class => $f_source_name, source => $f_source_name, - _original_name => $rel, cond => $cond, attrs => $attrs }; $self->_relationships(\%rels); @@ -1865,12 +1882,17 @@ sub _resolve_relationship_condition { $self->throw_exception("Arguments 'self_alias' and 'foreign_alias' may not be identical") if $args->{self_alias} eq $args->{foreign_alias}; +# TEMP + my $exception_rel_id = "relationship '$args->{rel_name}' on source '@{[ $self->source_name ]}'"; + my $rel_info = $self->relationship_info($args->{rel_name}) # TEMP # or $self->throw_exception( "No such $exception_rel_id" ); or carp_unique("Requesting resolution on non-existent relationship '$args->{rel_name}' on source '@{[ $self->source_name ]}': fix your code *soon*, as it will break with the next major version"); - my $exception_rel_id = "relationship '$rel_info->{_original_name}' on source '@{[ $self->source_name ]}'"; +# TEMP + $exception_rel_id = "relationship '$rel_info->{_original_name}' on source '@{[ $self->source_name ]}'" + if $rel_info and exists $rel_info->{_original_name}; $self->throw_exception("No practical way to resolve $exception_rel_id between two data structures") if exists $args->{self_result_object} and exists $args->{foreign_values}; @@ -1890,9 +1912,13 @@ sub _resolve_relationship_condition { ) ; - my $rel_rsrc = $self->related_source($args->{rel_name}); +#TEMP + my $rel_rsrc;# = $self->related_source($args->{rel_name}); if (exists $args->{foreign_values}) { +# TEMP + $rel_rsrc ||= $self->related_source($args->{rel_name}); + if (defined blessed $args->{foreign_values}) { $self->throw_exception( "Objects supplied as 'foreign_values' ($args->{foreign_values}) must inherit from DBIx::Class::Row" ) @@ -1954,6 +1980,9 @@ sub _resolve_relationship_condition { "The join-free condition returned for $exception_rel_id must be a hash reference" ) unless ref $jfc eq 'HASH'; +# TEMP + $rel_rsrc ||= $self->related_source($args->{rel_name}); + my ($joinfree_alias, $joinfree_source); if (defined $args->{self_result_object}) { $joinfree_alias = $args->{foreign_alias}; @@ -2141,6 +2170,9 @@ sub _resolve_relationship_condition { next if $col_eqs->{$lhs} eq UNRESOLVABLE_CONDITION; +# TEMP + $rel_rsrc ||= $self->related_source($args->{rel_name}); + # there is no way to know who is right and who is left in a cref # therefore a full blown resolution call, and figure out the # direction a bit further below @@ -2274,6 +2306,9 @@ sub handle { my $global_phase_destroy; sub DESTROY { + ### NO detected_reinvoked_destructor check + ### This code very much relies on being called multuple times + return if $global_phase_destroy ||= in_global_destruction; ###### @@ -2341,25 +2376,6 @@ sub throw_exception { ; } -=head2 source_info - -Stores a hashref of per-source metadata. No specific key names -have yet been standardized, the examples below are purely hypothetical -and don't actually accomplish anything on their own: - - __PACKAGE__->source_info({ - "_tablespace" => 'fast_disk_array_3', - "_engine" => 'InnoDB', - }); - -=head2 new - - $class->new(); - - $class->new({attribute_name => value}); - -Creates a new ResultSource object. Not normally called directly by end users. - =head2 column_info_from_storage =over @@ -2376,14 +2392,16 @@ Enables the on-demand automatic loading of the above column metadata from storage as necessary. This is *deprecated*, and should not be used. It will be removed before 1.0. +=head1 FURTHER QUESTIONS? -=head1 AUTHOR AND CONTRIBUTORS - -See L and L in DBIx::Class +Check the list of L. -=head1 LICENSE +=head1 COPYRIGHT AND LICENSE -You may distribute this code under the same terms as Perl itself. +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. =cut