squeel
squeel copied to clipboard
Select non-column
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;
Not beautiful to see, but it works: Model.select { _(1).as(one) } .where { id == 1 }