There are two entity Users and Profile.
They binded by OneToOne relation via fields:
Field $profile has @API\ApiSubresource() annotation. Api-platform creates route /api/users/1/profile.
But when I try to GET data by this URL I occurs an error:
Type error: Argument 1 passed to Doctrine\ORM\Mapping\DefaultQuoteStrategy::getJoinColumnName() must be of the type array, boolean given, called in C:\TEST\backend\vendor\doctrine\orm\lib\Doctrine\ORM\Query\AST\Functions\IdentityFunction.php on line 89
In case of using either ManyToOne or OneToMany associations all working perfectly.
Users.php
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation as API;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*
* @API\ApiResource()
*/
class Users
{
/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Profile
* @ORM\OneToOne(targetEntity="Profile", mappedBy="user")
* @API\ApiSubresource()
*/
private $profile;
// Other properties, getters and setters next ...
}
Profile.php
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation as API;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*
* @API\ApiResource()
*/
class Profile
{
/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Users
* @ORM\OneToOne(targetEntity="Users", inversedBy="profile")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $user;
// Other properties, getters and setters next ...
}
Could you please provide a reproducer for this ?
@Simperfit Here you are https://github.com/and-xdev/api-test
Routes:
/api/users/1/profile - does not work
/api/users/1/balances - works
Any clue about this? Got the same error...
I found the issue, and created PR for solving it: https://github.com/api-platform/core/pull/2228. Hopefully it will be ok, and could be merged.
Is fixed!
Most helpful comment
Any clue about this? Got the same error...