Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Support $useKeys option when EagerCursor converts to an array #223

Merged
merged 2 commits into from
Aug 17, 2015
Merged

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Aug 14, 2015

Fixes #160.

@jmikola jmikola added this to the 1.2.0 milestone Aug 14, 2015
@jmikola
Copy link
Member Author

jmikola commented Aug 17, 2015

@alcaeus: Can you take a look at this Monday?

@alcaeus
Copy link
Member

alcaeus commented Aug 17, 2015

The changes look good 👍
Do we want to expose this in the Builder or Query class so that it can be controlled by developers?

@jmikola
Copy link
Member Author

jmikola commented Aug 17, 2015

Do we want to expose this in the Builder or Query class so that it can be controlled by developers?

@alcaeus: Possibly. At the moment, it appears the only way to specify $useKeys would be to let the query builder return a cursor and then invoke toArray() on it manually. The Query class' own toArray() method doesn't currently pass through the option. getSingleResult() does so, but that's simply because Cursor::getSingleResult() always sets it on its own.

This may be because we're being strict about Doctrine MongoDB's Iterator and IteratorAggregate interfaces, neither of whose toArray() methods take an argument.

@@ -107,7 +121,7 @@ public function getSingleResult()
public function initialize()
{
if ($this->initialized === false) {
$this->data = $this->cursor->toArray();
$this->data = $this->cursor->toArray($this->useKeys);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we discussed moving $useKeys to an initialize() parameter, integration with ODM would benefit from keeping this as a constructor argument. That is because ODM's Cursor class (if we remove its EagerCursor) will merely wrap a CursorInterface.

jmikola and others added 2 commits August 17, 2015 15:50
This will be used in ODM to disable useKeys on all eager cursors.
@jmikola jmikola merged commit afcc829 into master Aug 17, 2015
jmikola added a commit that referenced this pull request Aug 17, 2015
@jmikola jmikola deleted the gh-160 branch August 17, 2015 19:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants