Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1801

PostgreSQL - quoting identifiers also quotes aliases

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.7
    • Component/s: None
    • Security Level: All
    • Labels:
      None
    • Environment:
      Symfony2

      Description

      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.name, p.surname, p.photographerguid')
              ->where("p.name = '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.

        Activity

        Hide
        ross neacoders added a comment -

        Duplicate of DDC-1695
        (will report there)

        Show
        ross neacoders added a comment - Duplicate of DDC-1695 (will report there)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            ross neacoders
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: