granite icon indicating copy to clipboard operation
granite copied to clipboard

Issue with `group_by` ?

Open sardaukar opened this issue 4 years ago • 3 comments

I'm using granite 0.19.0 and there seems to be an issue with group_by or I'm making a mistake somewhere.

If I define a model, I can query it with #all and #order just fine, but #group_by gives me:

Showing last frame. Use --error-trace for full trace.

In src/commands/build/content_loader.cr:28:24

 28 | puts ContentItem.group_by(:published_at)
                       ^-------
Error: undefined method 'group_by' for ContentItem.class

What am I doing wrong?

sardaukar avatar Apr 08 '20 20:04 sardaukar

By the way, doing puts ContentItem.where.group_by(:published_at).select works.

sardaukar avatar Apr 08 '20 20:04 sardaukar

I think group_by just needs added to https://github.com/amberframework/granite/blob/master/src/granite/query/builder_methods.cr#L15

Blacksmoke16 avatar Apr 08 '20 20:04 Blacksmoke16

Willing to improve https://github.com/amberframework/granite/pull/388 with some pointers!

sardaukar avatar Apr 08 '20 21:04 sardaukar