Skip to content


DDC-1801: PostgreSQL - quoting identifiers also quotes aliases #2457

doctrinebot opened this Issue · 2 comments

2 participants


Jira issue originally created by user rivaros:

First of all, I fully agree with Roman Borshell's concept that if you want identifier to be quoted you need to do it manually in Entity by back-ticking it.

That's what I did:

     * @var string $name
     * @ORM\Column(name="`Name`", type="string", length=50, nullable=false)
    private $name;

     * @var string $surname
     * @ORM\Column(name="`Surname`", type="string", length=50, nullable=false)
    private $surname;

But when I ran a simple query

        $qb = $repository->createQueryBuilder('p');
        $query = $qb
        ->select(', p.surname, p.photographerguid')
        ->where(" = 'Peter'");

        echo $query->getQuery()->getSQL();

what I get is TERRIBLE output

SELECT p0*."Name" AS "Name"0, p0_."Surname" AS "Surname"1, p0_."PhotographerGUID" AS "PhotographerGUID"2 FROM "Photographers" p0_ WHERE p0*."Name" = 'Peter' 

It also quoted identifiers like "Surname"1, "Name"0.

I spent 3 hours digging your code, and finally found in Doctrine\ORM\Query\SqlWalker.php Ln: 969

                $columnName = $class->getQuotedColumnName($fieldName, $this->_platform);

                $columnAlias =  $this->getSQLColumnAlias($columnName);

You quote column and then pass it to getSQLColumnAlias which appends some number to the end.

Is there a fix already in newer versions? Where can i find it then - will definitely make a port to this one.


Comment created by rivaros:

Duplicate of DDC-1695
(will report there)


Issue was closed with resolution "Duplicate"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.7 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.