[Bast-commits] r4626 - DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Jul 25 01:43:29 BST 2008
Author: rafl
Date: 2008-07-25 01:43:29 +0100 (Fri, 25 Jul 2008)
New Revision: 4626
Modified:
DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm
Log:
Only hook into create_related if we're relating to children.
Modified: DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm
===================================================================
--- DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm 2008-07-25 00:43:22 UTC (rev 4625)
+++ DBIx-Class-Tree-NestedSet/lib/DBIx/Class/Tree/NestedSet.pm 2008-07-25 00:43:29 UTC (rev 4626)
@@ -87,18 +87,20 @@
sub create_related {
my ($self, $rel, $col_data) = @_;
- my ($root, $left, $right) = map {
- $self->tree_columns->{"${_}_column"}
- } qw/root left right/;
+ if ($rel eq 'children') {
+ my ($root, $left, $right) = map {
+ $self->tree_columns->{"${_}_column"}
+ } qw/root left right/;
- my $p_rgt = $self->$right;
+ my $p_rgt = $self->$right;
- $self->nodes_rs->update({
- $left => \"CASE WHEN $left > $p_rgt THEN $left + 2 ELSE $left END",
- $right => \"CASE WHEN $right >= $p_rgt THEN $right + 2 ELSE $right END",
- });
+ $self->nodes_rs->update({
+ $left => \"CASE WHEN $left > $p_rgt THEN $left + 2 ELSE $left END",
+ $right => \"CASE WHEN $right >= $p_rgt THEN $right + 2 ELSE $right END",
+ });
- @$col_data{$root, $left, $right} = ($self->$root, $p_rgt, $p_rgt + 1);
+ @$col_data{$root, $left, $right} = ($self->$root, $p_rgt, $p_rgt + 1);
+ }
return $self->next::method($rel => $col_data);
}
More information about the Bast-commits
mailing list