Skip to content

Commit 3a872cb

Browse files
committed
feat: hasMany support
1 parent c869109 commit 3a872cb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/postgresql.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ PostgreSQL.prototype.buildJoin = function(model, filter) {
810810
}
811811
const relation =
812812
modelDefinition.settings.__relations__[candidateRelation];
813-
// Only supports belongsTo and hasOne
814-
if (relation.type !== 'belongsTo' && relation.type !== 'hasOne') {
813+
// Only supports belongsTo, hasOne and hasMany
814+
if (relation.type !== 'belongsTo' && relation.type !== 'hasOne' && relation.type !== 'hasMany') {
815815
debug('Invalid relation type for model %s for inner join', parentModel);
816816
break;
817817
}
@@ -958,7 +958,8 @@ PostgreSQL.prototype.buildJoin = function(model, filter) {
958958
innerJoin.relation.keyTo,
959959
true,
960960
innerJoin.prefix,
961-
)}${innerJoin.relation.type === 'hasOne' ? '::uuid' : ''} `;
961+
)}${innerJoin.relation.type === 'hasOne'
962+
|| innerJoin.relation.type === 'hasMany' ? '::uuid' : ''} `;
962963
}
963964

964965
return {

0 commit comments

Comments
 (0)