Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-3042

select issue field names with numbers

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3.3, 2.4.1, 2.4.2
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:
      None

      Description

      $qb = $this->_em->createQueryBuilder();
      $qb->select('k.aktiv, k.id, k.firma, k.firma2, k.strasse, k.plz, k.ort, k.plzpostfach, k.postfach, k.bemerkung,
               k.uuid, k.telefon,k.telefonzentrale, k.istmutter, k.isttochter, k.email, k.internet, k.fax, l.id as land, m.id as mutter, m.firma as mutterv, t.id as tochter, t.firma as tochterv, kg.id as kundengruppe, s.id as sic, s.title as sicv,
               kg.title as kundengruppev,m.telefon as telefonmutter,t.telefon as telefontochter, k.id as kdnr')
      

      will create this sql:

      SELECT c0_.id AS id0, c0_.aktiv AS aktiv1, c0_.firma AS firma2, c0_.firma2 AS firma23, c0_.strasse AS strasse4, c0_.plz AS plz5, c0_.ort AS ort6, c0_.plzpostfach AS plzpostfach7, c0_.postfach AS postfach8, c0_.hotel AS hotel9, c0_.kuerzel AS kuerzel10, c0_.stornofrist AS stornofrist11, c0_.uuid AS uuid12, c0_.telefon AS telefon13, c0_.telefonzentrale AS telefonzentrale14, c0_.istmutter AS istmutter15, c0_.isttochter AS isttochter16, c0_.trainer AS trainer17, c0_.email AS email18, c0_.internet AS internet19, c0_.fax AS fax20, l6_.id AS id21, c3_.id AS id22, c3_.firma AS firma23, c3_.telefon AS telefon24, c0_.id AS id25, t1_.content AS anfahrt26, t2_.content AS beschreibung27 
      

      as you see, it will create co.firma2 as firma23 and c3_.firma AS firma23,

      now when you do:

      $query = $qb->getQuery();
      $result = $query->getArrayResult();
      
      Array
      (
          [0] => Array
              (
                  [id] => 11
                  [aktiv] => 1
                  [firma] => Test GmbH
                  [mutterv] => Mutter Test
                  [strasse] => 
                  [plz] => 
                  [ort] => 
                  [plzpostfach] => 
                  [postfach] => 
                  [hotel] => 
                  [kuerzel] => 
                  [stornofrist] => 0
                  [uuid] => 524459b5-7f1c-442b-98dd-3d5cc0a81420
                  [telefon] => 0211/415583810
                  [telefonzentrale] => 
                  [istmutter] => 
                  [isttochter] => 
                  [trainer] => 
                  [email] => 
                  [internet] => 
                  [fax] => 
                  [land] => 3
                  [mutter] => 
                  [telefonmutter] => 
                  [kdnr] => 11
                  [anfahrt] => 
                  [beschreibung] => 
              )
      )
      

      when i change the order of the select , it will work

       $qb->select('k.id, k.aktiv, k.firma, k.strasse, k.plz, k.ort, k.plzpostfach, k.postfach, k.hotel, k.kuerzel, k.stornofrist,  k.firma2,
               k.uuid, k.telefon,k.telefonzentrale, k.istmutter, k.isttochter, k.trainer, k.email, k.internet, k.fax, l.id as land, m.id as mutter, m.firma as mutterv,
               m.telefon as telefonmutter, k.id as kdnr, k.anfahrt, k.beschreibung')
      

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment -

          Marc Lindemann can you reduce the example to only the fields that are affected? Does this affect also latest ORM?

          Show
          Marco Pivetta added a comment - Marc Lindemann can you reduce the example to only the fields that are affected? Does this affect also latest ORM?
          Hide
          Marc Lindemann added a comment - - edited

          Marco, the Problem only exists when you select like my example

          c0_.id AS id0, c0_.aktiv AS aktiv1, c0_.firma AS firma2, (...),  c0_.firma2 AS firma23, 
          

          as you see "firma2" is on the fourth place so it´s selected as "firma23", "m.firma" is on place 24, so it´s also selected as "firma23" (m.firma as mutterv)

          Show
          Marc Lindemann added a comment - - edited Marco, the Problem only exists when you select like my example c0_.id AS id0, c0_.aktiv AS aktiv1, c0_.firma AS firma2, (...), c0_.firma2 AS firma23, as you see "firma2" is on the fourth place so it´s selected as "firma23", "m.firma" is on place 24, so it´s also selected as "firma23" (m.firma as mutterv)
          Hide
          Marco Pivetta added a comment -

          Marc Lindemann ah, I see it now. This probably requires a change in how the DQL is generated by prefixing numerical indexes with something like an `_`.

          Show
          Marco Pivetta added a comment - Marc Lindemann ah, I see it now. This probably requires a change in how the DQL is generated by prefixing numerical indexes with something like an `_`.
          Hide
          Marco Pivetta added a comment -

          Marc Lindemann I provided a fix at https://github.com/doctrine/doctrine2/pull/985 - can you try it?

          Show
          Marco Pivetta added a comment - Marc Lindemann I provided a fix at https://github.com/doctrine/doctrine2/pull/985 - can you try it?
          Hide
          Marc Lindemann added a comment -

          Yeah, this works.

          Show
          Marc Lindemann added a comment - Yeah, this works.
          Hide
          Doctrine Bot added a comment -

          A related Github Pull-Request [GH-985] was closed:
          https://github.com/doctrine/doctrine2/pull/985

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-985] was closed: https://github.com/doctrine/doctrine2/pull/985
          Show
          Marco Pivetta added a comment - Merged: https://github.com/doctrine/doctrine2/commit/bfb66f1d85509db9e24ce33e30382c8cccaf2dd7

            People

            • Assignee:
              Marco Pivetta
              Reporter:
              Marc Lindemann
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: