Keep a unique field where update needs it, and a buffer a buffer - #1
Merged
Merged
Conversation
Contributor
|
All contributors have signed the @imqueue Contribution Terms. ✅ |
Collaborator
Author
|
I have read the CLA Document and I hereby sign the CLA |
Two defects in the query extensions, both silent.
accessScope nested the caller's `where` inside `AND` when it added its
filters. That is correct for `findMany` and fatal for `update`, `delete`
and `findUnique`: those take a `WhereUniqueInput`, and Prisma requires a
unique field at its *top level*, so moving `id` one level down left the
argument with no unique field and Prisma refused the call rather than
scoping it. Every scoped update in every service using this failed — in
scope or out — and a service that logs rather than rethrows reported it
to its caller as a save that succeeded and changed nothing.
The caller's own conditions now stay at the top level and only ours go
into `AND`, with their `AND` conjoined rather than overwritten. Top-level
conditions and `AND` conjoin, so a caller supplying their own value for a
scope column still gets ours and cannot widen past it.
isoDates rebuilt every object through `Object.entries`, so a `Buffer`
came back as `{ "0": 137, "1": 80, … }` — one key per byte, fifty times
the size, and no longer anything `Buffer.isBuffer` recognises. A `Bytes`
column read through the extension arrived unusable and the failure
looked like the row not existing. Typed arrays and `ArrayBuffer` are now
returned as they came; none of them can hold a `Date`, so there was
never anything in them to walk for.
`toIsoDates` is exported so it can be tested without a database, as
`accessWhere` already is.
Claude-Session: https://claude.ai/code/session_017BfLMdWM8zt8y3QzJxKods
SerhiyGreench
force-pushed
the
fix-scoped-writes-and-binary-columns
branch
from
August 16, 2026 14:03
c88832c to
96c0fe9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Two defects in the query extensions, both silent.
accessScope nested the caller's
whereinsideANDwhen it added its filters. That is correct forfindManyand fatal forupdate,deleteandfindUnique: those take aWhereUniqueInput, and Prisma requires a unique field at its top level, so movingidone level down left the argument with no unique field and Prisma refused the call rather than scoping it. Every scoped update in every service using this failed — in scope or out — and a service that logs rather than rethrows reported it to its caller as a save that succeeded and changed nothing.The caller's own conditions now stay at the top level and only ours go into
AND, with theirANDconjoined rather than overwritten. Top-level conditions andANDconjoin, so a caller supplying their own value for a scope column still gets ours and cannot widen past it.isoDates rebuilt every object through
Object.entries, so aBuffercame back as{ "0": 137, "1": 80, … }— one key per byte, fifty times the size, and no longer anythingBuffer.isBufferrecognises. ABytescolumn read through the extension arrived unusable and the failure looked like the row not existing. Typed arrays andArrayBufferare now returned as they came; none of them can hold aDate, so there was never anything in them to walk for.toIsoDatesis exported so it can be tested without a database, asaccessWherealready is.Type of change
Checklist
npm test).Contribution terms (required)
I grant the project owner the right to license my contribution
commercially, royalty-free, my contribution stays available under
GPL-3.0, I keep my copyright, and I understand I will receive no fee for
it. If I did not agree, I would not be submitting this contribution.
https://claude.ai/code/session_017BfLMdWM8zt8y3QzJxKods