Fix $obj->search to use $obj->result_source->resultset->search.
[dbsrgits/DBIx-Class-Tree.git] / lib / DBIx / Class / Tree / AdjacencyList / Positional.pm
index 97e4149..ebe0f85 100644 (file)
@@ -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