You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Separate: true — Cannot read property 'push' of undefined #7514
db.Outfits.hasMany(db.Likes, { foreignKey: 'outfit', as: 'likes' }); Outfits.findAll({ include: [ { model: Likes, attributes: [ 'user' ], as: 'likes', separate: true } ]})
So in my case same error appeared because of foreignKey 'outfit' lacking in attributes.
@andrew-polyansky So have you tried to add 'foreignKey' to associations? The problematic part of code looks like below. for (const instance of results) { result[instance.get(association.foreignKey, {raw: true})].push(instance); }
Anyway it's good to have some warnings on this case or at least to document it somehow.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Reacted by Brad Isbell, Luqmanul, Loop-Donsky and Mohamed Mirghani
Reacted by Chia Yu Pai, jimmy, Artyom Kolesen, Ryan McAlister, Alex.Dai, Kenny Hammerlund, WD, Emanuel Acevedo, Tizian Adam, 恶魔卡波姆 and 19 more
Reacted by Emanuel Acevedo, Tizian Adam, William Desportes, Adam Dabbracci, Faizan Ahmed and Ahmad Ul Hoq Nadim
Reacted by jimmy, Ryan, Dmitriy Pushkov, Ole Andreas Jørnsen Herland, Tizian Adam, fd-rey, William Desportes, Scottie, kayorl, Adam Dabbracci and 4 more
Reacted by Witthawin Sirisiwaphak, jimmy, WD, Emanuel Acevedo, Tizian Adam, William Desportes, Scottie, Adam Dabbracci, aroub1, zeeshanLT and 2 more
Reacted by Ayan Majumder, quy-q and Ahmad Ul Hoq Nadim
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
Activity
xdroidx commentedon May 24, 2017
I have just forced with same problem. In my case:
db.Outfits.hasMany(db.Likes, { foreignKey: 'outfit', as: 'likes' });Outfits.findAll({ include: [ { model: Likes, attributes: [ 'user' ], as: 'likes', separate: true } ]})So in my case same error appeared because of foreignKey 'outfit' lacking in attributes.
@andrew-polyansky So have you tried to add 'foreignKey' to associations? The problematic part of code looks like below.
for (const instance of results) { result[instance.get(association.foreignKey, {raw: true})].push(instance); }Anyway it's good to have some warnings on this case or at least to document it somehow.
stale commentedon Jul 23, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
jrcrawfo commentedon Jul 25, 2017
Still an issue
edwinvanrijkom commentedon Aug 22, 2017
Running into this as well (v.4.6.0).
elhoyos commentedon Aug 25, 2017
I got to make it work on my side by specifying the
foreignKeyin the included attributes.I'm using [email protected] on postgres.
zeing commentedon Sep 19, 2017
@elhoyos omg , you help me <3
anstill commentedon Sep 21, 2017
For resolve this issue need:
antl3x commentedon Oct 29, 2017
Using Sequelize 4.19.0 and this not solved.
flamewow commentedon Nov 14, 2017
got same issue
narin commentedon Nov 16, 2017
Having this issue as well. Including the foreign key in attributes as @elhoyos suggested did not solve the issue for me. Using 4.22.7.
stale commentedon Feb 14, 2018
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
1 remaining item
fareshan commentedon May 15, 2018
this is not resolved yet
sushantdhiman commentedon May 15, 2018
@fareshan You tried with which version?
fareshan commentedon May 15, 2018
@sushantdhiman v4.37.7
sushantdhiman commentedon May 15, 2018
@fareshan It's fixed in latest v5 beta
fareshan commentedon May 15, 2018
@sushantdhiman ok thanks
Is there a workaround for v4 ?
I am using sequelize-typescript which still does not support v5 yet
ebaynaud commentedon Nov 16, 2018
no workaround available for v4?
matamune94 commentedon Jun 28, 2019
Hi @sushantdhiman ,I make error Cannot read property 'push' of undefined, maybe can help ?
tiagoravache commentedon Aug 27, 2019
Same error sequelize version 5.8.5, and the suggest of @elhoyos doesn't work here...any other suggestion?
papb commentedon Aug 27, 2019
@matamune94 @tiagoravache Please open a new issue (following the template) and linking to this issue as a reference.
kanwarmanish commentedon Jan 1, 2023
sequelize: 5.21.2 - still an issue. Could any body resolve it?
caseyt commentedon Dec 9, 2024
Still an issue as of v 7.0. This repo is terrible about closing issues that still exist.