X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSource.pm;h=a0263397cfd5c53e90c6b46677380b93a40a9a86;hb=cb136e67f71c272de046dfab5cec183f78cb5e08;hp=d21cdb719ff03c1501774cd9d55206d2a85cecfd;hpb=5d9d9e87f31d3f8ac98d6e013f5b23eac4bcd40d;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index d21cdb7..a026339 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -143,6 +143,12 @@ generate a new key value. If not specified, L will attempt to retrieve the name of the sequence from the database automatically. +=item auto_nextval + +Set this to a true value for a column whose value is retrieved +automatically from an oracle sequence. If you do not use an oracle +trigger to get the nextval, you have to set sequence as well. + =item extra This is used by L and L @@ -519,6 +525,14 @@ sub add_relationship { unless $cond; $attrs ||= {}; + # Check foreign and self are right in cond + if ( (ref $cond ||'') eq 'HASH') { + for (keys %$cond) { + $self->throw_exception("Keys of condition should be of form 'foreign.col', not '$_'") + if /\./ && !/^foreign\./; + } + } + my %rels = %{ $self->_relationships }; $rels{$rel} = { class => $f_source_name, source => $f_source_name, @@ -632,7 +646,7 @@ sub reverse_relationship_info { my $otherrel_info = $othertable->relationship_info($otherrel); my $back = $othertable->related_source($otherrel); - next unless $back->name eq $self->name; + next unless $back->source_name eq $self->source_name; my @othertestconds; @@ -782,7 +796,7 @@ sub resolve_condition { $self->throw_exception("Invalid rel cond val ${v}"); if (ref $for) { # Object #warn "$self $k $for $v"; - $ret{$k} = $for->get_column($v); + $ret{$k} = $for->get_column($v) if $for->has_column_loaded($v); #warn %ret; } elsif (!defined $for) { # undef, i.e. "no object" $ret{$k} = undef; @@ -891,6 +905,16 @@ sub resolve_prefetch { $self->throw_exception( "Can't prefetch has_many ${pre} (join cond too complex)") unless ref($rel_info->{cond}) eq 'HASH'; + my $dots = @{[$as_prefix =~ m/\./g]} + 1; # +1 to match the ".${as_prefix}" + if (my ($fail) = grep { @{[$_ =~ m/\./g]} == $dots } + keys %{$collapse}) { + my ($last) = ($fail =~ /([^\.]+)$/); + $self->throw_exception( + "Can't prefetch multiple has_many rels ${last} and ${pre}" + .(length($as_prefix) ? "at the same level (${as_prefix})" + : "at top level" + )); + } #my @col = map { (/^self\.(.+)$/ ? ("${as_prefix}.$1") : ()); } # values %{$rel_info->{cond}}; $collapse->{".${as_prefix}${pre}"} = [ $rel_source->primary_columns ]; @@ -972,7 +996,9 @@ but is cached from then on unless resultset_class changes. Set the class of the resultset, this is useful if you want to create your own resultset methods. Create your own class derived from -L, and set it here. +L, and set it here. If called with no arguments, +this method returns the name of the existing resultset class, if one +exists. =head2 resultset_attributes @@ -1049,6 +1075,15 @@ sub throw_exception { } } +=head2 sqlt_deploy_hook($sqlt_table) + +An optional sub which you can declare in your own Schema class that will get +passed the L object when you deploy the schema +via L or L. + +For an example of what you can do with this, see +L. + =head1 AUTHORS Matt S. Trout