Skip to content

[DDC-1819][WIP] Arbitrary object hydrator#348

Closed
marijn wants to merge 3 commits intodoctrine:masterfrom
marijn:DDC-1819-arbitrary-object-hydrator
Closed

[DDC-1819][WIP] Arbitrary object hydrator#348
marijn wants to merge 3 commits intodoctrine:masterfrom
marijn:DDC-1819-arbitrary-object-hydrator

Conversation

@marijn
Copy link

@marijn marijn commented May 14, 2012

Initial work (in progress) on a test suite for the arbitrary object hydrator, as discussed in DDC-1819. Any tips are appreciated. I'm not too sure what the test suite should and should not cover.

Other questions I have include:

  1. Should the HYDRATE_ARBITRARY_OBJECT constant be added to the AbstractQuery class or the NativeQuery class? It only makes sense in the former but it might be missed when more constants are added in the future...
  2. Should I use data providers in my tests for the result set data?
  3. Should my tests be added to a DDC1819 namespace?
  4. Should I add functional tests?

marijn added 3 commits May 14, 2012 11:03
The model consists of two entities: Customer and Address. The models are linked
to one another through a one to one relationship that is owned by the customer.

There third object represents the combined data for both models. This
CustomerAddressView object will be used to test the arbitrary object hydration.
The suite contains a single test which mimics a query spanning two tables.
This results in the following API:

    $rsm = new Doctrine\ORM\Query\ResultSetMapping();

    // Create the result set mapping

    $query = $em->createNativeQuery($sql, $rsm);
    $objects = $query->getResult(Doctrine\ORM\Query::HYDRATE_ARBITRARY_OBJECT);
@travisbot
Copy link

This pull request fails (merged a2f9bc0 into 4ef552e).

@marijn
Copy link
Author

marijn commented May 14, 2012

Perhaps we should rename ResultSetMapping::addEntityResult to ResultSetMapping::addObjectResult?

I think it would be better to create a separate method for mapping arbitrary objects.

@beberlei
Copy link
Member

why?

@Ocramius
Copy link
Member

@marijn as discussed 2 days ago, I don't really think your use case is valid. Anyway, I'd try another way, which is making up a Doctrine\ORM\Mapping\ClassMetadata instance and passing it to the hydrator. Didn't dig into it, but the SympleObjectHydrator#prepare method has some logic you could try to reuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants