rails/arel — Issue #89: Can't chain other operators or #as, etc from addition or subtraction
Author: stevecj
Created: 2011-10-21 21:49:39+00:00
State: open

An addition or subtraction results in a Nodes::Grouping instance, and that class does not have the mixins to support chaining additional methods. I can't even specify a column name using #as (e.g. (foo_table[:value] + 1).as(foo_plus_one). Attempting to do so results in...

NoMethodError: undefined method `as' for #

Likewise, I can't chain an addition to an addition, etc. The same problem does not exist for multiplication and division, because those return instances of Nodes::Binary subclasses rather than Nodes::Grouping.

It seems to me that the addition and subtraction operators should return instances of something like a MathGrouping class that includes the same mixins that Nodes::Binary and Attributes::Attribute do (and maybe there should be another module that encapsulates that combination of inclusions).