tchandy/octopus — pull request #207 by nickmarden (2013-11-20 04:02:37+00:00)
Title: [DO NOT MERGE]

(Please don't merge this yet, even if you think it's awesome sauce. We're still testing and I want to make sure that it doesn't create more problems than it solves!)

@tchandy: This branch demonstrates a concrete example of the "double select" bug in 7aeb8d3 and then proposes a technique for solving it in f649abf. My implementation of QueryOnCurrentShard is decidedly incomplete (it only includes .all and .exists?, but it provides a simple array of ActiveRecord::Relation methods that can be forced to operate on the current shard if one exists.

This patch also includes the more extensive list of shard-safe AssociationCollection methods.