maZahaca/sonata-admin-tree-bundle

SQl Error on get_class and dql with config[root] always empty

Clanver opened this issue · 0 comments

Hey, nice work here.
After fumbling with the configurations i got everthing to work.

But i needed to change up two things in my own bundle to get it to work. Not sure why though . . might be my own inability but i will describe it either way. Maybe someone can explain what i did wrong?

So after configuring everything for the "StofDoctrineExtensionsBundle" my category entity just would not show a category tree properly. The ajax always returned a SQL Error.

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: ""
in vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php (line 95)

I followed the error in the code and it seemed like my CategoryAdmin class returned something wrong in the getClass() method.

So i´ve overwritten it and returned the proper entity class since it is used later to get the repository.

Fine, now it works, but always returns an empty array. . .

After looking into it, it seems like the NestedTreeRepository just cant find anything when a root is configured.

if (isset($config['root'])) { $qb->andWhere($qb->expr()->eq('node.'.$config['root'], ':rid')); $qb->setParameter('rid', $wrapped->getPropertyValue($config['root'])); }
Since the root field is always empty in my database, it wont find anything. Dont really know when the root field is written. I cant write it manually ..

So i removed the root configuration in my xml config:
gedmo:tree-root/ <<< removed

Now it properly works, but im not sure if what ive done was ok.

Did someone have similar problems?