From: Aran Deltac Date: Mon, 27 Mar 2006 22:08:39 +0000 (+0000) Subject: Fix $obj->search to use $obj->result_source->resultset->search. X-Git-Tag: 0.03001~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e338251bec21568f78a72f89ddb009a4edba8edb;p=dbsrgits%2FDBIx-Class-Tree.git Fix $obj->search to use $obj->result_source->resultset->search. --- diff --git a/Build.PL b/Build.PL index 27dabe7..ab17675 100644 --- a/Build.PL +++ b/Build.PL @@ -6,7 +6,7 @@ my %arguments = ( license => 'perl', module_name => 'DBIx::Class::Tree', requires => { - 'DBIx::Class' => 0.05, + 'DBIx::Class' => 0.06, }, build_requires => { 'DBD::SQLite' => 1.11, diff --git a/lib/DBIx/Class/Tree/AdjacencyList.pm b/lib/DBIx/Class/Tree/AdjacencyList.pm index 4ceada2..d1ef803 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList.pm @@ -107,7 +107,7 @@ the objects one level below the current one. sub children { my( $self ) = @_; - my $rs = $self->search( + my $rs = $self->result_source->resultset->search( { $self->parent_column()=>$self->id() } ); return $rs->all() if (wantarray()); diff --git a/lib/DBIx/Class/Tree/AdjacencyList/Positional.pm b/lib/DBIx/Class/Tree/AdjacencyList/Positional.pm index 97e4149..ebe0f85 100644 --- a/lib/DBIx/Class/Tree/AdjacencyList/Positional.pm +++ b/lib/DBIx/Class/Tree/AdjacencyList/Positional.pm @@ -83,13 +83,16 @@ sub parent { my( $self, $new_parent ) = @_; if ($new_parent) { if (ref($new_parent)) { - $new_parent = $new_parent->id() || 0; + $new_parent = $new_parent->id() || croak('Parent object does not have an id'); } return 0 if ($new_parent == ($self->get_column($self->parent_column())||0)); $self->move_last(); return 0 if (!$self->next::method( $new_parent )); $self->set_column( - $self->position_column() => $self->search( {$self->_collection_clause()} )->count() + 1 + $self->position_column() => + $self->result_source->resultset->search( + {$self->_collection_clause()} + )->count() + 1 ); $self->update(); return 1; @@ -112,7 +115,7 @@ orders the children by there position. sub children { my( $self ) = @_; - my $rs = $self->search( + my $rs = $self->result_source->resultset->search( { $self->parent_column() => $self->id() }, { order_by => $self->position_column() } ); @@ -184,6 +187,18 @@ sub attach_after { These methods are used internally. You should never have the need to use them. +=head2 collection_column + +Postional's collection_column method does not, and should not, be +defined when using this module. This method just throws out an +error if you try to use it. + +=cut + +sub collection_column { + croak('Use parent_column() instead of collection_column()'); +} + =head2 _collection_clause This method is provided as an override of the method in