Out of interest, i was attempting to rewrite
Model.joins{other_model}.uniq
(which generates):
=> "SELECT DISTINCT [model].* FROM [model] INNER JOIN [other_model] ON [other_model].[model_id] = [model].[id]"
In pure Squeel, however the closest i can get is
Model.joins{other_model}.select{distinct(id)}
Which generates:
=> "SELECT DISTINCT [model].[id] FROM [model] INNER JOIN [other_model] ON [other_model].[model_id] = [model].[id]"
How would i do a DISTINCT [model].*
in Squeel? Is it possible?
Thanks
You need to quote the * in backticks
Model.select{distinct(`*`)}.to_sql
Produces:
SELECT distinct(*) from `models`