[Bast-commits] r6323 - in
DBIx-Class/0.08/branches/joined_count/lib: DBIx/Class
DBIx/Class/CDBICompat DBIx/Class/Relationship
SQL/Translator/Parser/DBIx
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue May 19 17:34:19 GMT 2009
Author: ribasushi
Date: 2009-05-19 17:34:19 +0000 (Tue, 19 May 2009)
New Revision: 6323
Modified:
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/CDBICompat/ImaDBI.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Accessor.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Base.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/ManyToMany.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSource.pm
DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Row.pm
DBIx-Class/0.08/branches/joined_count/lib/SQL/Translator/Parser/DBIx/Class.pm
Log:
Hide resultsource methods that should have never been documented
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/CDBICompat/ImaDBI.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/CDBICompat/ImaDBI.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/CDBICompat/ImaDBI.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -55,7 +55,7 @@
$self->throw_exception( "No relationship to JOIN from ${from_class} to ${to_class}" )
unless $rel_obj;
my $join = $from_class->storage->sql_maker->_join_condition(
- $from_class->result_source_instance->resolve_condition(
+ $from_class->result_source_instance->_resolve_condition(
$rel_obj->{cond}, $to, $from) );
return $join;
}
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Accessor.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Accessor.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Accessor.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -27,7 +27,7 @@
} elsif (exists $self->{_relationship_data}{$rel}) {
return $self->{_relationship_data}{$rel};
} else {
- my $cond = $self->result_source->resolve_condition(
+ my $cond = $self->result_source->_resolve_condition(
$rel_info->{cond}, $rel, $self
);
if ($rel_info->{attrs}->{undef_on_null_fk}){
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Base.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Base.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/Base.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -189,7 +189,7 @@
my $query = ((@_ > 1) ? {@_} : shift);
my $source = $self->result_source;
- my $cond = $source->resolve_condition(
+ my $cond = $source->_resolve_condition(
$rel_obj->{cond}, $rel, $self
);
if ($cond eq $DBIx::Class::ResultSource::UNRESOLVABLE_CONDITION) {
@@ -404,7 +404,7 @@
unless Scalar::Util::blessed($f_obj) and $f_obj->isa($f_class);
}
$self->set_columns(
- $self->result_source->resolve_condition(
+ $self->result_source->_resolve_condition(
$rel_obj->{cond}, $f_obj, $rel));
return 1;
}
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/ManyToMany.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/ManyToMany.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Relationship/ManyToMany.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -119,7 +119,7 @@
my $obj = shift;
my $rel_source = $self->search_related($rel)->result_source;
my $cond = $rel_source->relationship_info($f_rel)->{cond};
- my $link_cond = $rel_source->resolve_condition(
+ my $link_cond = $rel_source->_resolve_condition(
$cond, $obj, $f_rel
);
$self->search_related($rel, $link_cond)->delete;
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSet.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -505,7 +505,7 @@
&& ($info = $self->result_source->relationship_info($key))) {
my $val = delete $input_query->{$key};
next KEY if (ref($val) eq 'ARRAY'); # has_many for multi_create
- my $rel_q = $self->result_source->resolve_condition(
+ my $rel_q = $self->result_source->_resolve_condition(
$info->{cond}, $val, $key
);
die "Can't handle OR join condition in find" if ref($rel_q) eq 'ARRAY';
@@ -1626,7 +1626,7 @@
next unless $data->[$index]->{$rel} && ref $data->[$index]->{$rel} eq "HASH";
my $result = $self->related_resultset($rel)->create($data->[$index]->{$rel});
my ($reverse) = keys %{$self->result_source->reverse_relationship_info($rel)};
- my $related = $result->result_source->resolve_condition(
+ my $related = $result->result_source->_resolve_condition(
$result->result_source->relationship_info($reverse)->{cond},
$self,
$result,
@@ -1659,7 +1659,7 @@
my $child = $parent->$rel;
- my $related = $child->result_source->resolve_condition(
+ my $related = $child->result_source->_resolve_condition(
$parent->result_source->relationship_info($rel)->{cond},
$child,
$parent,
@@ -2446,14 +2446,14 @@
my $seen = { %{$attrs->{seen_join}||{}} };
# we need to take the prefetch the attrs into account before we
- # ->resolve_join as otherwise they get lost - captainL
+ # ->_resolve_join as otherwise they get lost - captainL
my $merged = $self->_merge_attr( $attrs->{join}, $attrs->{prefetch} );
- push @$from, $source->resolve_join($merged, $attrs->{alias}, $seen) if ($merged);
+ push @$from, $source->_resolve_join($merged, $attrs->{alias}, $seen) if ($merged);
++$seen->{-relation_chain_depth};
- push @$from, $source->resolve_join($extra_join, $attrs->{alias}, $seen);
+ push @$from, $source->_resolve_join($extra_join, $attrs->{alias}, $seen);
++$seen->{-relation_chain_depth};
@@ -2553,7 +2553,7 @@
$attrs->{from} = # have to copy here to avoid corrupting the original
[
@{ $attrs->{from} },
- $source->resolve_join(
+ $source->_resolve_join(
$join, $alias, { %{ $attrs->{seen_join} || {} } }
)
];
@@ -2582,7 +2582,7 @@
# bring joins back to level of current class
my $join_map = $self->_joinpath_aliases ($attrs->{from}, $attrs->{seen_join});
my @prefetch =
- $source->resolve_prefetch( $p, $alias, $join_map, \@pre_order, $collapse );
+ $source->_resolve_prefetch( $p, $alias, $join_map, \@pre_order, $collapse );
push( @{ $attrs->{select} }, map { $_->[0] } @prefetch );
push( @{ $attrs->{as} }, map { $_->[1] } @prefetch );
}
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSource.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSource.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/ResultSource.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -841,7 +841,7 @@
=back
Throws an exception if the condition is improperly supplied, or cannot
-be resolved using L</resolve_join>.
+be resolved.
=cut
@@ -881,7 +881,7 @@
}
return unless $f_source; # Can't test rel without f_source
- eval { $self->resolve_join($rel, 'me') };
+ eval { $self->_resolve_join($rel, 'me') };
if ($@) { # If the resolve failed, back out and re-throw the error
delete $rels{$rel}; #
@@ -1015,29 +1015,22 @@
my @other_cond = keys(%$othercond);
my @other_refkeys = map {/^\w+\.(\w+)$/} @other_cond;
my @other_keys = map {$othercond->{$_} =~ /^\w+\.(\w+)$/} @other_cond;
- next if (!$self->compare_relationship_keys(\@refkeys, \@other_keys) ||
- !$self->compare_relationship_keys(\@other_refkeys, \@keys));
+ next if (!$self->_compare_relationship_keys(\@refkeys, \@other_keys) ||
+ !$self->_compare_relationship_keys(\@other_refkeys, \@keys));
$ret->{$otherrel} = $otherrel_info;
}
}
return $ret;
}
-=head2 compare_relationship_keys
-
-=over 4
-
-=item Arguments: \@keys1, \@keys2
-
-=item Return value: 1/0 (true/false)
-
-=back
-
-Returns true if both sets of keynames are the same, false otherwise.
-
-=cut
-
sub compare_relationship_keys {
+ carp 'compare_relationship_keys is a private method, stop calling it';
+ my $self = shift;
+ $self->_compare_relationship_keys (@_);
+}
+
+# Returns true if both sets of keynames are the same, false otherwise.
+sub _compare_relationship_keys {
my ($self, $keys1, $keys2) = @_;
# Make sure every keys1 is in keys2
@@ -1070,25 +1063,18 @@
return $found;
}
-=head2 resolve_join
-
-=over 4
-
-=item Arguments: $relation
-
-=item Return value: Join condition arrayref
-
-=back
-
-Returns the join structure required for the related result source.
-
-=cut
-
sub resolve_join {
+ carp 'resolve_join is a private method, stop calling it';
+ my $self = shift;
+ $self->_resolve_join (@_);
+}
+
+# Returns the {from} structure used to express JOIN conditions
+sub _resolve_join {
my ($self, $join, $alias, $seen, $force_left, $jpath) = @_;
# we need a supplied one, because we do in-place modifications, no returns
- $self->throw_exception ('You must supply a seen hashref as the 3rd argument to resolve_join')
+ $self->throw_exception ('You must supply a seen hashref as the 3rd argument to _resolve_join')
unless $seen;
$force_left ||= { force => 0 };
@@ -1104,7 +1090,7 @@
return
map {
local $force_left->{force} = $force_left->{force};
- $self->resolve_join($_, $alias, $seen, $force_left, [@$jpath]);
+ $self->_resolve_join($_, $alias, $seen, $force_left, [@$jpath]);
} @$join;
} elsif (ref $join eq 'HASH') {
return
@@ -1112,8 +1098,8 @@
my $as = ($seen->{$_} ? join ('_', $_, $seen->{$_} + 1) : $_); # the actual seen value will be incremented below
local $force_left->{force} = $force_left->{force};
(
- $self->resolve_join($_, $alias, $seen, $force_left, [@$jpath]),
- $self->related_source($_)->resolve_join(
+ $self->_resolve_join($_, $alias, $seen, $force_left, [@$jpath]),
+ $self->related_source($_)->_resolve_join(
$join->{$_}, $as, $seen, $force_left, [@$jpath, $_]
)
);
@@ -1140,27 +1126,20 @@
-join_alias => $as,
-relation_chain_depth => $seen->{-relation_chain_depth} || 0,
},
- $self->resolve_condition($rel_info->{cond}, $as, $alias) ];
+ $self->_resolve_condition($rel_info->{cond}, $as, $alias) ];
}
}
-=head2 pk_depends_on
-
-=over 4
-
-=item Arguments: $relname, $rel_data
-
-=item Return value: 1/0 (true/false)
-
-=back
-
-Determines whether a relation is dependent on an object from this source
-having already been inserted. Takes the name of the relationship and a
-hashref of columns of the related object.
-
-=cut
-
sub pk_depends_on {
+ carp 'pk_depends_on is a private method, stop calling it';
+ my $self = shift;
+ $self->_pk_depends_on (@_);
+}
+
+# Determines whether a relation is dependent on an object from this source
+# having already been inserted. Takes the name of the relationship and a
+# hashref of columns of the related object.
+sub _pk_depends_on {
my ($self, $relname, $rel_data) = @_;
my $cond = $self->relationship_info($relname)->{cond};
@@ -1189,23 +1168,18 @@
return 1;
}
-=head2 resolve_condition
+sub resolve_condition {
+ carp 'resolve_condition is a private method, stop calling it';
+ my $self = shift;
+ $self->_resolve_condition (@_);
+}
-=over 4
-
-=item Arguments: $cond, $as, $alias|$object
-
-=back
-
-Resolves the passed condition to a concrete query fragment. If given an alias,
-returns a join condition; if given an object, inverts that object to produce
-a related conditional from that object.
-
-=cut
-
+# Resolves the passed condition to a concrete query fragment. If given an alias,
+# returns a join condition; if given an object, inverts that object to produce
+# a related conditional from that object.
our $UNRESOLVABLE_CONDITION = \'1 = 0';
-sub resolve_condition {
+sub _resolve_condition {
my ($self, $cond, $as, $for) = @_;
#warn %$cond;
if (ref $cond eq 'HASH') {
@@ -1246,75 +1220,38 @@
}
return \%ret;
} elsif (ref $cond eq 'ARRAY') {
- return [ map { $self->resolve_condition($_, $as, $for) } @$cond ];
+ return [ map { $self->_resolve_condition($_, $as, $for) } @$cond ];
} else {
die("Can't handle this yet :(");
}
}
-=head2 resolve_prefetch
+sub resolve_prefetch {
+ carp 'resolve_prefetch is a private method, stop calling it';
+ my $self = shift;
+ $self->_resolve_prefetch (@_);
+}
-=over 4
+# Accepts one or more relationships for the current source and returns an
+# array of column names for each of those relationships. Column names are
+# prefixed relative to the current source, in accordance with where they appear
+# in the supplied relationships. Needs an alias_map generated by
+# $rs->_joinpath_aliases
-=item Arguments: hashref/arrayref/scalar
-
-=back
-
-Accepts one or more relationships for the current source and returns an
-array of column names for each of those relationships. Column names are
-prefixed relative to the current source, in accordance with where they appear
-in the supplied relationships. Examples:
-
- my $source = $schema->resultset('Tag')->source;
- @columns = $source->resolve_prefetch( { cd => 'artist' } );
-
- # @columns =
- #(
- # 'cd.cdid',
- # 'cd.artist',
- # 'cd.title',
- # 'cd.year',
- # 'cd.artist.artistid',
- # 'cd.artist.name'
- #)
-
- @columns = $source->resolve_prefetch( qw[/ cd /] );
-
- # @columns =
- #(
- # 'cd.cdid',
- # 'cd.artist',
- # 'cd.title',
- # 'cd.year'
- #)
-
- $source = $schema->resultset('CD')->source;
- @columns = $source->resolve_prefetch( qw[/ artist producer /] );
-
- # @columns =
- #(
- # 'artist.artistid',
- # 'artist.name',
- # 'producer.producerid',
- # 'producer.name'
- #)
-
-=cut
-
-sub resolve_prefetch {
+sub _resolve_prefetch {
my ($self, $pre, $alias, $alias_map, $order, $collapse, $pref_path) = @_;
$pref_path ||= [];
if( ref $pre eq 'ARRAY' ) {
return
- map { $self->resolve_prefetch( $_, $alias, $alias_map, $order, $collapse, [ @$pref_path ] ) }
+ map { $self->_resolve_prefetch( $_, $alias, $alias_map, $order, $collapse, [ @$pref_path ] ) }
@$pre;
}
elsif( ref $pre eq 'HASH' ) {
my @ret =
map {
- $self->resolve_prefetch($_, $alias, $alias_map, $order, $collapse, [ @$pref_path ] ),
- $self->related_source($_)->resolve_prefetch(
+ $self->_resolve_prefetch($_, $alias, $alias_map, $order, $collapse, [ @$pref_path ] ),
+ $self->related_source($_)->_resolve_prefetch(
$pre->{$_}, "${alias}.$_", $alias_map, $order, $collapse, [ @$pref_path, $_] )
} keys %$pre;
return @ret;
Modified: DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Row.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/DBIx/Class/Row.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -112,7 +112,7 @@
->resultset
->new_result($data);
}
- if ($self->result_source->pk_depends_on($relname, $data)) {
+ if ($self->result_source->_pk_depends_on($relname, $data)) {
MULTICREATE_DEBUG and warn "MC $self constructing $relname via find_or_new";
return $self->result_source
->related_source($relname)
@@ -132,7 +132,7 @@
foreach my $key (keys %$reverse) {
# if their primary key depends on us, then we have to
# just create a result and we'll fill it out afterwards
- return 1 if $rel_source->pk_depends_on($key, $us);
+ return 1 if $rel_source->_pk_depends_on($key, $us);
}
return 0;
}
@@ -304,7 +304,7 @@
next REL unless (Scalar::Util::blessed($rel_obj)
&& $rel_obj->isa('DBIx::Class::Row'));
- next REL unless $source->pk_depends_on(
+ next REL unless $source->_pk_depends_on(
$relname, { $rel_obj->get_columns }
);
@@ -913,7 +913,7 @@
next unless $rel_info->{attrs}{cascade_copy};
- my $resolved = $self->result_source->resolve_condition(
+ my $resolved = $self->result_source->_resolve_condition(
$rel_info->{cond}, $rel, $new
);
Modified: DBIx-Class/0.08/branches/joined_count/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/joined_count/lib/SQL/Translator/Parser/DBIx/Class.pm 2009-05-19 17:26:21 UTC (rev 6322)
+++ DBIx-Class/0.08/branches/joined_count/lib/SQL/Translator/Parser/DBIx/Class.pm 2009-05-19 17:34:19 UTC (rev 6323)
@@ -113,7 +113,7 @@
my @primary = $source->primary_columns;
my %unique_constraints = $source->unique_constraints;
foreach my $uniq (sort keys %unique_constraints) {
- if (!$source->compare_relationship_keys($unique_constraints{$uniq}, \@primary)) {
+ if (!$source->_compare_relationship_keys($unique_constraints{$uniq}, \@primary)) {
$table->add_constraint(
type => 'unique',
name => $uniq,
@@ -167,7 +167,7 @@
# this is supposed to indicate a has_one/might_have...
# where's the introspection!!?? :)
else {
- $fk_constraint = not $source->compare_relationship_keys(\@keys, \@primary);
+ $fk_constraint = not $source->_compare_relationship_keys(\@keys, \@primary);
}
my $cascade;
More information about the Bast-commits
mailing list