Skip to content

Separate: true — Cannot read property 'push' of undefined #7514

@anstill

Description

@anstill
Model.hasMany(AnotherMmodelWithHasManyAssociations, { onDelete: 'CASCADE', as: 'test' });
Model.findAll({
        include: [
            {
                model: AnotherMmodelWithHasManyAssociations,
                as: 'test',
                separate: true,
            },
        ],
    })

After that Sequelize falls with error:

TypeError: Cannot read property 'push' of undefined
     at /usr/src/app/node_modules/sequelize/lib/associations/has-many.js:331:64
     at Array.forEach (native)
     at .<anonymous> (/usr/src/app/node_modules/sequelize/lib/associations/has-many.js:330:13)
 From previous event:
     at Promise.then (/usr/src/app/node_modules/sequelize/lib/promise.js:21:17)
     at HasMany.get (/usr/src/app/node_modules/sequelize/lib/associations/has-many.js:322:33)
     at /usr/src/app/node_modules/sequelize/lib/model.js:1442:32
 From previous event:
     at Function.map (/usr/src/app/node_modules/sequelize/lib/promise.js:21:17)
     at Function.Model.$findSeparate (/usr/src/app/node_modules/sequelize/lib/model.js:1420:18)
     at .<anonymous> (/usr/src/app/node_modules/sequelize/lib/model.js:1408:18)
 From previous event:
     at Promise.then (/usr/src/app/node_modules/sequelize/lib/promise.js:21:17)
     at Promise.all.then (/usr/src/app/src/modules/transaction/limits.service.js:139:10)

Dialect: mariaDb
Database version: 10.1
Sequelize version: 3.30.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    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