Repository navigation
fix(orm): don't build an empty IN() when zero rows match an update/updateMany on MySQL - #2887
krist7599555 wants to merge 2 commits into
Conversation
…dateMany on MySQL loadAfterMutationEntities treated an empty preUpdateIds array as truthy, building `WHERE (id) IN ()` for any zero-match update/updateMany once an afterEntityMutation hook is registered. MySQL (no RETURNING support) rejects that as a syntax error — breaking every zero-match write app-wide, including ones a policy plugin legitimately denies down to zero rows. Fixes zenstackhq#2886
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Summary
loadAfterMutationEntitiestreated an emptypreUpdateIds/mutatedIdsarray as truthy, so a zero-matchupdate/updateManyon MySQL (noRETURNINGsupport) builtWHERE (id) IN ()once any plugin registered anafterEntityMutationhook — invalid SQL, thrown app-wide for every zero-match write, not just the hooked model.[]directly, distinct from the existingundefined("can't determine ids at all") branch which still warns.Test plan
tests/regression/test/issue-2886.test.ts: fails againstdevHEAD with the exactER_PARSE_ERRORfrom the issue, passes with this fix.tests/e2e/orm/plugin-infra/entity-mutation-hooks.test.ts(35 tests) still green against MySQL with the fix applied.🤖 Generated with Claude Code
Summary by CodeRabbit