Why isn’t everyone using Squeel?

Squeel was originally intended to become part of the official Active Record API and is implemented by monkey-patching Active Record internals and overriding Active Record’s query methods.
Unfortunately for all of us, that inclusion never happened, and it left Squeel susceptible to breakage from arbitrary changes in Active Record.

Introducing: BabySqueel

BabySqueel provides a Squeel-like query DSL for Active Record while attempting to avoid version upgrade difficulties that hamstrung Squeel by avoiding monkey-patches to the ever-changing Active Record internals.

Ugh… repetition. That’s a contrived example, but you can imagine what happens on larger projects with more complicated business logic. Here is the equivalent code, built using BabySqueel. Pay attention to the fact that sifters can be combined and return little bits of logic using Arel.

(Bad) reasons not to use BabySqueel

Won’t BabySqueel be brittle? What about Rails 6?

BabySqueel currently supports both Rails 4 and 5 with very little code needed to accommodate specific versions. BabySqueel’s goal is to avoid the majority of version upgrade difficulties by keeping monkey-patching to an absolute minimum.

Like Squeel and Ransack, BabySqueel depends on Polyamorous. While Polyamorous does monkey-patch Active Record’s JoinDependency to allow outer joining specific relations, it is extremely well-tested and is always up to date with the latest versions of Active Record.

In the future, it is very unlikely that BabySqueel would prevent you from upgrading Rails.

I’m already using Squeel. Won’t migrating be hard?

Nope, it’s easy.
Because the API is so similar to Squeel’s, the migration process can usually be completed with a couple of find-and-replaces.
Check out the migration guide for more details.

If you’re desperate, you can turn on compatibility mode, which makes it even easier to move to BabySqueel.
But try to only use Compatibility Mode as a stepping stone.