Skip to content

[DDC-2055] Generate SELECT clause from ResultSetMappingBuilder #462

Merged
merged 2 commits into from Oct 5, 2012

3 participants

@beberlei
Doctrine member
beberlei commented Oct 3, 2012

Add support to generate entity result parts of the SELECT clause from a ResultSetMappingBuilder instance. Add support for column incrementing.

Sample:

$rsm = new ResultSetMappingBuilder($entityManager);
$rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u');

$sql = "SELECT " . $rsm . " FROM users u";
$result = $entityManager->createNativeQuery($sql, $rsm)->getResult();

TestCase Usage:

public function testGenerateSelectClauseIncrement()
{
    $rsm = new ResultSetMappingBuilder($this->_em);
    $rsm->addRootEntityFromClassMetadata('Doctrine\Tests\Models\CMS\CmsUser', 'u', ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);

    $selectClause = $rsm->generateSelectClause();

    $this->assertEquals('u.id AS id0, u.status AS status1, u.username AS username2, u.name AS name3, u.email_id AS email_id4', $selectClause);
}

Restrictions:

This only generates the entity result clauses, not the ones for scalar results! Because we don't know what the scalar result actually means.

@beberlei beberlei [DDC-2055] Add support to generate entity result parts of the SELECT …
…clause from a ResultSetMappingBuilder instance. Add support for column incrementing.
913377e
@doctrinebot

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2056

@stof stof commented on an outdated diff Oct 3, 2012
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
{
$classMetadata = $this->em->getClassMetadata($class);
+ $platform = $this->em->getConnection()->getDatabasePlatform();
@stof
Doctrine member
stof added a note Oct 3, 2012

@guilhermeblanco will ask you to align the = :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@beberlei beberlei merged commit a0440b6 into master Oct 5, 2012

1 check passed

Details default The Travis build passed
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.