Skip to content

feat(client): expose ModelName to compute function in Result extensions - #29181

Closed
vic-blt wants to merge 1 commit into
prisma:mainfrom
vic-blt:feat/client-extension-result-context
Closed

vic-blt wants to merge 1 commit into
prisma:mainfrom
vic-blt:feat/client-extension-result-context

Conversation

@vic-blt

@vic-blt vic-blt commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #19821

Pass an extra parameter named modelName to compute function in result extension.
It will allow to create condition based on model name in compute function for $allModels.

Summary by CodeRabbit

  • Improvements

    • Extension compute functions now receive the model name as an additional parameter, enabling context-aware computations and allowing extensions to tailor results based on which model is being processed.
  • Tests

    • Added unit test coverage verifying that the model name is available to extension compute functions at compute time, ensuring correct behavior and preventing regressions.

@CLAassistant

CLAassistant commented Feb 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Propagates modelName into extension compute functions: type signatures and runtime helpers were changed to pass modelName through the computation pipeline, and a unit test was added to verify compute functions under $allModels receive the modelName.

Changes

Cohort / File(s) Summary
Type Signatures
packages/client/src/runtime/core/types/exported/ExtensionArgs.ts, packages/client/src/runtime/core/types/exported/Extensions.ts
Updated compute-related types so ResultArgsFieldCompute and DynamicResultExtensionArgs.compute accept a second modelName parameter (arity changed from one to two).
Runtime Implementation
packages/client/src/runtime/core/extensions/applyResultExtensions.ts, packages/client/src/runtime/core/extensions/resultUtils.ts
Modified computedPropertyLayer and composeCompute to accept and forward modelName, and updated calls to invoke field.compute(result, modelName).
Test Coverage
packages/client/src/runtime/core/extensions/applyResultExtensions.test.ts
Added a unit test asserting that modelName is available inside a compute function defined under $allModels.
🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: exposing modelName as a parameter to compute functions in Result extensions.
Linked Issues check ✅ Passed The PR successfully implements the requested feature by passing modelName as a second argument to compute functions in Result extensions, enabling $allModels compute functions to access the model name.
Out of Scope Changes check ✅ Passed All code changes are directly scoped to exposing modelName to compute functions: type definitions, implementation updates, and test coverage. No unrelated modifications detected.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vic-blt
vic-blt force-pushed the feat/client-extension-result-context branch from 09a2855 to c8c3736 Compare February 13, 2026 11:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

@vic-blt
vic-blt force-pushed the feat/client-extension-result-context branch 2 times, most recently from 8c6e5f9 to ad16e9d Compare February 13, 2026 11:41
@vic-blt
vic-blt force-pushed the feat/client-extension-result-context branch from ad16e9d to ae70e0f Compare February 13, 2026 11:43
@tensordreams
tensordreams changed the base branch from main to v7 July 21, 2026 12:08
@tensordreams
tensordreams changed the base branch from v7 to main July 21, 2026 15:13
@tensordreams

Copy link
Copy Markdown
Contributor

Hi @vic-blt — thanks for this, and apologies that it sat for so long.

We're clearing the open PR backlog ahead of moving this codebase to a v7 branch, with the Prisma Next rewrite taking over main.

We are closing this one as inactive: the CLA has not been signed and there has been no response since February. The change itself is clean — if the feature is wanted we may implement it directly.

If you would still like to pursue it, sign the CLA and reopen the PR and we will take another look.

@vic-blt

vic-blt commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Hi @vic-blt — thanks for this, and apologies that it sat for so long.

We're clearing the open PR backlog ahead of moving this codebase to a v7 branch, with the Prisma Next rewrite taking over main.

We are closing this one as inactive: the CLA has not been signed and there has been no response since February. The change itself is clean — if the feature is wanted we may implement it directly.

If you would still like to pursue it, sign the CLA and reopen the PR and we will take another look.

Hello @tensordreams , I've just signed the CLA and I'll reopen the PR.
Thx for the update.

aqrln pushed a commit that referenced this pull request Jul 27, 2026
…ns (#29782)

Closes #19821
Reopens #29181 following comment of
@tensordreams

Pass an extra parameter named modelName to compute function in result
extension.
It will allow to create condition based on model name in compute
function for $allModels.
lh0x00 pushed a commit to lh0x00/prisma that referenced this pull request Aug 9, 2026
…ns (prisma#29782)

Closes prisma#19821
Reopens prisma#29181 following comment of
@tensordreams

Pass an extra parameter named modelName to compute function in result
extension.
It will allow to create condition based on model name in compute
function for $allModels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't get model name when extending prisma client

3 participants