Re: Re: Group by on joined table in 1.1.0.rc1
Xavier (DBIYF <
xavier@...>
2011-03-01 22:26:23 GMT
On 2/03/11 9:24 AM, Josiah wrote:
> Aha, yeah, I was asking for how to do it in the database (somehow I
> glossed over the fact that group_by was not a datamapper call and it
> was not actually issuing a group by in sql). Is there a way to do
> group by without sorting by that field as well? I'd like to be able
> to sort by one column and group by another.
Please provide the concrete SQL query you are trying to achieve
(or the input with expected output)
My brain doesn't work with Foo and joinedtable ;)
>
> Thanks for your help so far,
> Josiah
>
> On Mar 1, 2:16 pm, Xavier Shay<xav...@...> wrote:
>> On Mar 2, 6:03 am, Josiah<bluep...@...> wrote:> What is the
api for grouping by and sorting by a joined table in 1.1?
>>
>>> eg:
>>
>>> Foo.all( ... ).group_by(&:'joinedtable.some_field')
>>
>> I'm not convinced this a datamapper method ... #group_by is provided
>> by activesupport, and you're using it with a proc. This happens in
>> ruby land, not in the DB, meaning you can do this:
>> .group_by {|record| record.joined_table.some_field }
>>
>>
(Continue reading)