squeel icon indicating copy to clipboard operation
squeel copied to clipboard

Select non-column

Open MarkMurphy opened this issue 11 years ago • 1 comments

Is there a way so do this in squeel:

SELECT 1 AS one FROM `table_name` WHERE id = '1' 

If not, I'd like to put this in as a feature request.

I tried this but it obviously doesn't work:

Model.select{1.as(one)}.where{id.eq(1)}

Here's the actual query I'm trying to construct using squeel:

SELECT users.*, (SELECT 1 AS one FROM relationships WHERE follower_id = :user_id AND followee_id = users.id) AS followed FROM users;

MarkMurphy avatar Sep 05 '14 18:09 MarkMurphy

Not beautiful to see, but it works: Model.select { _(1).as(one) } .where { id == 1 }

carlosvini avatar Sep 05 '14 18:09 carlosvini