Skip to content

Group by is propagating to separated includes #9748

@mjamado

Description

@mjamado

What are you doing?

I have structures like this:

News » hasMany » NewsTranslations
News » hasMany » Sections » hasMany » SectionsTranslations

Sometimes I need the full structure, sometimes half, sometimes there's a where condition to the title of one of the translations. Bottom line is, I have semi-demi-ORM before the Sequelize ORM which builds (among other things) the necessary includes.

Because the findAndCountAll is sort of broken in v4 (I've heard it's fixed on v5, but can't upgrade on account of other stuff), I opted to separate: true the hasMany associations if and only if that association is not being used on where or order. If it is, I need to group by the main table primary key.

The problem arises because Sequelize applies that same group to the separate'd queries - which, of course, breaks them.

What do you expect to happen?

Not apply group to associations which are separate.

What is actually happening?

All hell breaks loose.

Suggestion

A simple modification to model.js on line 1681 works:

        // _.omit(options, 'include', 'attributes', 'order', 'where', 'limit', 'offset', 'plain'),
        _.omit(options, 'include', 'attributes', 'order', 'where', 'limit', 'offset', 'plain', 'group'),

But can it be done? Will it break something else for someone? Can it land on v4, or only for v5?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueFor issues. An issue that is a good choice for first-time contributors.type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions