Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Revise query builder API for map/reduce and group #64

merged 4 commits into from Jul 19, 2012


None yet
1 participant

jmikola commented Jul 16, 2012

BC breaks:

  • reduce(), finalize(), and out() no longer reset the query type to map/reduce
  • reduce() can no longer be used in place of where(). It seems like an improper use of reduce(), so I'd like to remove it. This use case isn't documented, and the relevant code was last touched in 445ec61. I also found an ODM test case for this behavior (which I would remove if we merge this down).
  • reduce() and finalize() will now raise an exception if the builder is not in the map/reduce or group query type state. Alternatively, we could store the argument into both the map/reduce and group arrays, but this seemed preferable.

jmikola added some commits Jul 16, 2012

[Query] Revise map/reduce builder method docs
Also avoid resetting the query type to map/reduce when out() is invoked.
[Query] Improve builder interface for group queries
 * Use separate options array for group queries
 * Handle condition and finalize options for group queries
 * Allow reduce() and finalize() to be used for both map/reduce and group queries
[Collection] Prepare reduce/finalize args for group queries
MongoCollection::group() will internally convert a string "reduce" argument to a MongoCode object, but it won't do it for the "finalize" option. Explicitly prepare both as we do in the map/reduce method.

Also, avoid calling MongoCollection::group() with an empty array as the options parameter, since this will trigger an E_DEPRECATED notice in version 1.2.11+ of the driver. That notice may be removed in version 1.3, but we should leave this in place until the deprecation notices are removed entirely in 2.0.

jmikola added a commit that referenced this pull request Jul 19, 2012

Merge pull request #64 from doctrine/group-options
Revise query builder API for map/reduce and group

@jmikola jmikola merged commit 17e9c5a into master Jul 19, 2012

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