redding/mr — pull request #166 by jcredding (2014-01-09 19:21:10+00:00)
Title: Fix `ReadModel` querying, keep expressions ordered via array

This reverts some of the changes made to `ReadModel` querying.
Expressions had been changed so that they were grouped in a
hash of arrays instead of a single flat array. This was so they
could easily be organized and to be efficient. This kept all
expressions of the same type orderd appropriately, but didn't
define a specific order when applying the different types.

This breaks down if a complex query uses a generic `merge`. For
these cases, the read model can't keep them ordered in an
appropriate order and expressions can easily get out of order.
To avoid this, this switches back to an array, which keeps all
expressions in the order they are applied to the read model. Thus,
it is up to the read model what order they go in, allowing the
developer to control it.

I expected this to be more inefficient for the `find` method, but
MR's benchmarks didn't suggest so. Maybe for a read model with
more expressions than what is benchmarked it would have a greater
effect on it's overall speed.

@kellyredding - This is a bug I ran into while integrating the new MR into our large app.