Browse files

sortable behavior: fixed rank shifting on delete when there are no re…

…lated objects
  • Loading branch information...
1 parent 7b0e087 commit f860b2039951a1ba615d4173b7698b4e79b85b12 @rozwell committed Nov 9, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 generator/lib/behavior/sortable/SortableRelationBehavior.php
View
4 generator/lib/behavior/sortable/SortableRelationBehavior.php
@@ -78,7 +78,9 @@ protected function addObjectMoveRelatedToNullScope(&$script)
public function {$this->getObjectMoveRelatedToNullScopeMethodName()}(PropelPDO \$con = null)
{
\$maxRank = $queryClass::create()->getMaxRank(\$this->getPrimaryKey(), \$con);
- $peerClass::shiftRank(\$maxRank, null, null, \$this->getPrimaryKey(), \$con);
+ if (null !== \$maxRank) { // getMaxRank() returns null for empty tables
+ $peerClass::shiftRank(\$maxRank, null, null, \$this->getPrimaryKey(), \$con);
+ }
}
";

0 comments on commit f860b20

Please sign in to comment.