Skip to content

Commit 1531d7e

Browse files
fixed for v4
1 parent 19ec7d2 commit 1531d7e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/services/association.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ export function setAssociations(target: any, associations: ISequelizeAssociation
141141
}
142142

143143
export function getAssociationsByRelation(target: any, relatedClass: any): ISequelizeAssociation[] {
144-
145144
const associations = getAssociations(target);
146145

147-
return (associations || []).filter(association =>
148-
association.relatedClassGetter().prototype === relatedClass.prototype);
146+
return (associations || []).filter(association => {
147+
const _relatedClass = association.relatedClassGetter();
148+
return (
149+
_relatedClass.prototype === relatedClass.prototype || // v3 + v4
150+
relatedClass.prototype instanceof _relatedClass // v4 (for child classes)
151+
);
152+
});
149153
}
150154

151155
/**

0 commit comments

Comments
 (0)