-
Notifications
You must be signed in to change notification settings - Fork 9.3k
fix: disallow undefined where clause #21062
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (05/01/25)1 reviewer was added to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mrge found 1 issue across 3 files. View it in mrge.io
$allModels: { | ||
async deleteMany({ args, query }) { | ||
checkUndefinedInValue(args.where); | ||
validateWhereClause(args.where); | ||
return query(args); | ||
}, | ||
async updateMany({ args, query }) { | ||
checkUndefinedInValue(args.where); | ||
validateWhereClause(args.where); | ||
return query(args); | ||
}, | ||
async findMany({ args, query }) { | ||
validateWhereClause(args.where); | ||
return query(args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we have this guard for these operations. Do we need to add more operations here?
it("validateWhereClause should throw exception when the where object is undefined", async () => { | ||
const where = undefined; | ||
|
||
expect(() => validateWhereClause(where)).toThrowError('The "where" clause cannot be undefined.'); | ||
}); | ||
|
||
it("validateWhereClause should throw exception when the where object is {}", async () => { | ||
const where = {}; | ||
|
||
expect(() => validateWhereClause(where)).toThrowError('The "where" clause cannot be an empty object {}.'); | ||
}); | ||
|
||
it("validateWhereClause should throw exception when the where object is []", async () => { | ||
const where = []; | ||
|
||
expect(() => validateWhereClause(where)).toThrowError('The "where" clause cannot be an empty array [].'); | ||
}); | ||
|
||
it("validateWhereClause should throw exception when the 'in' field of where object is []", async () => { | ||
const where = { | ||
id: { | ||
in: [], | ||
}, | ||
}; | ||
|
||
expect(() => validateWhereClause(where)).toThrowError( | ||
'The "in" value for the field "id" cannot be an empty array [].' | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new test
E2E results are ready! |
What does this PR do?
Summary by mrge
Disallowed undefined, empty object, and empty array values in Prisma where clauses to prevent invalid queries.