Skip to content

Keep a unique field where update needs it, and a buffer a buffer - #1

Merged
SerhiyGreench merged 1 commit into
masterfrom
fix-scoped-writes-and-binary-columns
Aug 16, 2026
Merged

Keep a unique field where update needs it, and a buffer a buffer#1
SerhiyGreench merged 1 commit into
masterfrom
fix-scoped-writes-and-binary-columns

Conversation

@SerhiyGreench

@SerhiyGreench SerhiyGreench commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

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.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / internal
  • Other:

Checklist

  • I have read the Contributing guide.
  • Tests added or updated, and the full suite passes locally (npm test).
  • Docs / doc-blocks updated where relevant.
  • The PR is focused on a single logical change.

Contribution terms (required)

  • I have read and agree to the @imqueue Contribution Terms.
    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

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the @imqueue Contribution Terms. ✅
Posted by the CLA Assistant Lite bot.

@SerhiyGreench

Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 16, 2026
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
SerhiyGreench force-pushed the fix-scoped-writes-and-binary-columns branch from c88832c to 96c0fe9 Compare August 16, 2026 14:03
@SerhiyGreench
SerhiyGreench merged commit a89f383 into master Aug 16, 2026
7 of 8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant