rails/arel — pull request #295 by ncolgan (2014-06-26 15:31:11+00:00)
Title: Fix named functions within subqueries

Arel is currently casting values compared against NamedFunctions improperly.

Using tables from the test suite, the statement

products.project(products[:id]).where(products[:id].in(users.project(users[:id]).where(users[:name].lower.eq('foo'))))

currently generates

(SELECT \"products\".\"id\" FROM \"products\" WHERE \"products\".\"id\" IN (SELECT \"users\".\"id\" FROM \"users\" WHERE LOWER(\"users\".\"name\") = 0))

With these changes, it properly generates

(SELECT \"products\".\"id\" FROM \"products\" WHERE \"products\".\"id\" IN (SELECT \"users\".\"id\" FROM \"users\" WHERE LOWER(\"users\".\"name\") = 'foo'))