Skip to content

Loading…

DDC-644: [ORACLE] setting query maxResults together with firstResult leads to an error #5153

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user cicovec:

I'm not very skilled in doctrine yet, but I found something that might be worth reporting.

The code below produces "Class does not exist" error, which is quite misleading and just a side effect of a Notice that shows up in AbstractHydrator.php (lines 190 and 191).

        $q = DBConnection::Common()->createQueryBuilder()->select('c')->from('COMPANY', 'c')->getQuery();
        $q->setMaxResults(15);
        $q->setFirstResult(1);
        var_dump($query->getResult());

The query becomes:

SELECT b.** FROM (SELECT a.**, ROWNUM AS doctrine*rownum FROM (SELECT c0_.ID_COMPANY AS ID_COMPANY0, c0_.CONTACT AS CONTACT1, c0_.CONTRACT AS CONTRACT2, c0_.DESCRIPTION AS DESCRIPTION3, c0_.ID_DISPLAY_CASE AS ID_DISPLAY_CASE4, c0_.MAX_OPEN_WIN AS MAX_OPEN_WIN5, c0_.NAME AS NAME6, c0_.REFRESH_TIME AS REFRESH_TIME7, c0_.STATUS AS STATUS8, c0_.TABLESPACE AS TABLESPACE9 FROM COMPANY c0_) a ) b WHERE doctrine*rownum BETWEEN 2 AND 16

The problem occurs when iterating over the list of internal column aliases (IDCOMPANY0,DESCRIPTION3,ID_DISPLAY_CASE4,MAX_OPEN_WIN5,NAME6,REFRESHTIME7,STATUS8,TABLESPACE9 and
DOCTRINEROWNUM). The last one "DOCTRINE_ROWNUM" is missing in both $this->_rsm->metaMappings and $this->rsm->columnOwnerMap and it's not a matter of case sensitivity, it's missing completely.

Result:

$cache[$key]['dqlAlias'] becomes NULL
$rowData[$dqlAlias][$cache[$key]['fieldName']] = $value;

(line 203) creates a new key (named as empty string) in $rowData and things get screwed up since then in further iterations over $rowData array.

Unfortunately I'm not familiar with the internal code of doctrine at all, and it seems too complex for me to be able to provide a fix (except for an ugly hack).

I've attached the Exception trace (might help).

BTW: Doctrine 2 is the cleanest piece of complex code I've ever seen. You guys rock !!!

@doctrinebot

Comment created by @beberlei:

fixed formating

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-BETA3 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.