-
-
Notifications
You must be signed in to change notification settings - Fork 132
feat: fields argument for @updatedAt
#2379
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
Open
sanny-io
wants to merge
6
commits into
zenstackhq:dev
Choose a base branch
from
sanny-io:feat/updated-at-fields
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b44df85
feat: `fields` argument for `@updatedAt`
sanny-io 02015fa
chore: add tests
sanny-io 4bcbb13
chore: remove old tests
sanny-io 3c87470
chore: update e2e schema
sanny-io 2bea83b
Address AI comments.
sanny-io 23a2dda
Trigger Build
sanny-io File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@updatedAt(ignore/fields)can miss relation-driven FK updates.hasUpdatedonly inspects scalar/foreign-key fields present in the inputdata. When a nested relation update changes owned FK fields (e.g.,author: { connect: ... }), those FK changes are applied later viaparentUpdates, sohasUpdatedstays false andupdatedAtis not bumped. This is a regression forignore/fieldsconfigurations.🛠️ Suggested fix (treat owned relation updates as FK updates)
📝 Committable suggestion
🤖 Prompt for AI Agents
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.
@ymc9 this doesn't seem like a regression. Was the original implementation of
ignorewrong?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.
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.
Hi @sanny-io , I think it's a valid issue. As @coderabbitai mentioned, if the model-under-update owns a relation and is doing a nested update to that relation, it'll result in an update to the fk field. So, if the
@updatedAtexplicitly includes the fk field, it won't trigger the timestamp update, because the fk field doesn't appear in the payload.I think we need a bit more analysis in the
updatedAt.fieldsbranch to identify relation update and translate them to fk fields.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.
@ymc9Thanks for confirming! You're absolutely right—the current logic only checks for scalar/FK fields present directly in thedataobject, so nested relation operations like{ author: { connect: ... } }that will update FK fields are completely missed.Looking at the schema structure, when a model owns a relation, the
fieldDef.relation.fieldsarray contains the FK field names that will be updated by that relation operation. The fix should check if any relation field in the data will trigger FK updates to:ignorecase)fieldscase)Would you like me to plan the code changes to implement this fix? I can create a detailed plan that:
hasUpdatedlogic to inspect relation fieldsrelation.fieldsLet me know if you'd like me to proceed with the planning, or if you prefer to handle this internally!
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.
@coderabbitai plan the code changes to implement the fix.
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.
Task: Fix updatedAt to account for relation-driven FK updates
The current
hasUpdatedlogic only checks scalar and FK fields present directly in thedataobject. When nested relation operations (e.g.,author: { connect: ... }) update owned FK fields, those changes happen later viaparentUpdatesand are missed. We need to:relation.fieldsignore/fieldsfiltering to those FK fieldsThis will ensure
@updatedAt(ignore: [...])and@updatedAt(fields: [...])work correctly with nested relation updates.💡 For code changes across multiple files, use
@coderabbitaiplan in an issue comment