0

I have followed the docs:

https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/tree.md#materialized-path

I am getting the following error:

 An exception occurred while executing 'UPDATE task SET path = ?, task_id = ?, lvl = ? WHERE id = ?' with params ["-1", "-1", 0, 1]:  
                                                                                                                                       
  SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'task_id' at row 1     

Here is my entity:

<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\MaterializedPathRepository")
 * @Gedmo\Tree(type="materializedPath")
 */
class Task
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer", options={"unsigned":true})
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=128, nullable=false)
     */
    private $title;

    /**
     * @ORM\Column(type="integer", nullable=true)
     * @Gedmo\TreeLevel
     */
    private $lvl;

    /**
     * @ORM\Column(type="integer", nullable=true)
     * @Gedmo\TreeLeft
     */
    private $lft;

    /**
     * @ORM\Column(type="integer", nullable=true)
     * @Gedmo\TreeRight
     */
    private $rgt;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\TreePath(separator=".", startsWithSeparator=false, endsWithSeparator=false)
     */
    private $path;

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Gedmo\TreePathSource
     */
    private $source;

    /**
     * @ORM\OneToMany(targetEntity="App\Entity\Task", mappedBy="parent")
     * @ORM\OrderBy({"lft":"ASC"})
     */
    private $children;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Task")
     * @ORM\JoinColumn(name="task_id", referencedColumnName="id", onDelete="CASCADE")
     * @Gedmo\TreeRoot
     */
    private $root;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Task", inversedBy="children")
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
     * @Gedmo\TreeParent
     */
    private $parent;

}

What am I not understanding or what am I missing about the configuration for materialized path?

Why are the node ID's coming up as negative also??? Very odd...

Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68
  • Can you show the code (probably controller action) which updates the Task-entity? – dbrumann Dec 21 '20 at 12:55
  • I followed the docs: https://github.com/Atlantic18/DoctrineExtensions/blob/v2.4.x/doc/tree.md#path-generation – Alex.Barylski Dec 21 '20 at 12:57
  • Could it be, because you set path to `startsWithSeparator=false, endsWithSeparator=false` (in the docs its false/true as default)? I would expect that at least one of them should be true. Maybe due to the "faulty" path it can't map to an id, that's just a wild guess though. Other than that I can only assume that the default method `getRoot()` expected for `@TreeRoot` does not exist on your entity – dbrumann Dec 21 '20 at 13:07

0 Answers0