For the same case, i have an another error :
No converter registered for type 'public.group',
I have, user, group and user_group tables.
$sql = <<<SQL
SELECT :projection
FROM "user"
LEFT JOIN user_group ON "user".id=user_group.user_id
LEFT JOIN "group" ON "group".id=user_group.group_id
WHERE "user".id = $*
GROUP BY "user".id
SQL;
$projection = $this->createProjection()
->setField('groups', 'array_agg("group") AS groups', 'public.group[]')
;
$sql = strtr($sql, [':projection' => (string) $projection->formatFields('"user"')]);
return $this->query($sql, [1], $projection);
In services.yaml :
App\Infrastructure\Model\MyDB\PublicSchema\GroupModel:
tags: [pomm.model]
App\Infrastructure\Model\MyDB\PublicSchema\UserGroupModel:
tags: [pomm.model]
App\Infrastructure\Model\MyDB\PublicSchema\UserModel:
tags: [pomm.model]
To ovoid having to register a converter for each table of the database, converters are loaded when tables model classes are loaded.
Adding the following line at the beginning of your method should resolve your problem:
$groupModel = $this->getSession()->getModel(GroupModel::class);
This also gives you the ability not to deal with the group
relation name as it is stored in the structure that comes with the model.