Skip to content

Loading…

DDC-3042: select issue field names with numbers #3812

Closed
doctrinebot opened this Issue · 9 comments

2 participants

@doctrinebot

Jira issue originally created by user rev83:

$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')
@doctrinebot

Comment created by @ocramius:

[~rev83] can you reduce the example to only the fields that are affected? Does this affect also latest ORM?

@doctrinebot

Comment created by rev83:

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)

@doctrinebot

Comment created by @ocramius:

[~rev83] ah, I see it now. This probably requires a change in how the DQL is generated by prefixing numerical indexes with something like an _.

@doctrinebot

Comment created by @ocramius:

[~rev83] I provided a fix at #985 - can you try it?

@doctrinebot

Comment created by rev83:

Yeah, this works.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-985] was closed:
#985

@doctrinebot

Comment created by @ocramius:

Merged: bfb66f1

@doctrinebot

Issue was closed with resolution "Fixed"

@Ocramius Ocramius was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 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.