Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(policy): revers lookup condition to parent entity is not properly built with compound id fields #2053

Merged
merged 7 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix undefined where conditions
  • Loading branch information
ymc9 committed Mar 23, 2025
commit 935d539dc63ce45eb3123fe65c811f038bc6a1ce
7 changes: 5 additions & 2 deletions packages/runtime/src/enhancements/node/policy/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1579,12 +1579,15 @@ export class PolicyProxyHandler<DbClient extends DbClientContract> implements Pr
if (this.shouldLogQuery) {
this.logger.info(
`[policy] \`findMany\` ${this.model}: ${formatObject({
where: args.where,
where: args.where ?? {},
select: candidateSelect,
})}`
);
}
const candidates = await tx[this.model].findMany({ where: args.where, select: candidateSelect });
const candidates = await tx[this.model].findMany({
where: args.where ?? {},
select: candidateSelect,
});

// build a ID filter based on id values filtered by the additional checker
const { idFilter } = this.buildIdFilterWithEntityChecker(candidates, entityChecker.func);
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/api/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ class RequestHandler extends APIHandlerBase {
args.take = limit;
const [entities, count] = await Promise.all([
prisma[type].findMany(args),
prisma[type].count({ where: args.where }),
prisma[type].count({ where: args.where ?? {} }),
]);
const total = count as number;

Expand Down
Loading