pvsaintpe / ltree-bundle

10 stars 5 forks source link

"Can't build path property without id" when inserting in entity using strategy="IDENTITY" #2

Closed sushicodeur closed 4 years ago

sushicodeur commented 4 years ago

Hi,

When inserting an item on an entity with an Id using strategy Identity, we get an error "Can\'t build path property without id". The same entity with a strategy="AUTO" works fine.

    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @ORM\Column(type="integer")
     */
    protected $id;

is there a workaround to keep using IDENTITY ?

Thank you

sushicodeur commented 4 years ago

So I forked the repo and used my branch in my project. The only change I made was to just return with no error when no id was present : https://github.com/studio-goliath/ltree-bundle/commit/dea9d50021f6301a621bd68ca3871e4d8676fe6a

We already had triggers in db generating these path, so everything works now.