Include NULL values using :group option?

I’m trying to use the :group option in an ActiveRecord association. I
wrote the code as follows:

class User < ActiveRecord::Base
has_many :messages, :group => “thread”, :order => “created_at desc”
end

It works fine as it returns some records. The problem is that the mysql
clause “GROUP BY” ignores NULL values. That makes that records with
thread == NULL not to show.

¿Is there a rails option to include NULL values when using :group?

Thanks,
Pablo

On Jan 26, 6:41 pm, Pablo G. [email protected] wrote:

¿Is there a rails option to include NULL values when using :group?

Given that the underlying DB doesn’t appear to support the operation,
I’d say not. Even if it did, the result would be that you’d only get
the most recent post with thread == NULL, which doesn’t seem like what
you’d want.

–Matt J.

I think you’re right. I’ve been looking for that solution and I didn’t
find anything really solving it. So I guess I must figure out another
approuch, perhaps giving a default value for “thread”.

Thank you anyway.