doctrine/orm

Make IDENTITY function work with joined columns

Open

#8043 aperta il 27 feb 2020

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)PHP (2539 fork)batch import
BugHacktoberfest

Metriche repository

Star
 (10.176 star)
Metriche merge PR
 (Merge medio 29g 6h) (13 PR mergiate in 30 g)

Descrizione

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

On https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html#dql-select-examples it is said

the IDENTITY() DQL function also works for composite primary keys

But if these keys are part of another association they won’t be found in fields but in associations mapping, hence throwing.

Example

Given the following entities

class Contract
{
    /**
     * @ORM\ManyToOne(targetEntity="Agent")
     * @ORM\Id
     */
    private $agent;

    /**
     * @ORM\ManyToOne(targetEntity="Agency")
     * @ORM\Id
     */
    private $agency;
}

class Estate
{
    /**
     * @ORM\ManyToOne(targetEntity="Contract")
     * @ORM\JoinColumns({
     *  @ORM\JoinColumn(name="contract_agent_id", referencedColumnName="agent_id"),
     *  @ORM\JoinColumn(name="contract_agency_id", referencedColumnName="agency_id"),
     * })
     */
    protected $contract;
}

I expected to be able to write IDENTITY(estate.contract, 'agent_id').

Is this something that could be implemented?

Guida contributor