-
Notifications
You must be signed in to change notification settings - Fork 55
Partial update #886
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
base: main
Are you sure you want to change the base?
Partial update #886
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6159,6 +6159,7 @@ public function updateDocument(string $collection, string $id, Document $documen | |
| $skipPermissionsUpdate = ($originalPermissions === $currentPermissions); | ||
| } | ||
| $createdAt = $document->getCreatedAt(); | ||
| $inputKeys = \array_keys($document->getArrayCopy()); | ||
|
|
||
| $document = \array_merge($old->getArrayCopy(), $document->getArrayCopy()); | ||
| $document['$collection'] = $old->getAttribute('$collection'); // Make sure user doesn't switch collection ID | ||
|
|
@@ -6334,7 +6335,11 @@ public function updateDocument(string $collection, string $id, Document $documen | |
|
|
||
| $document = $this->adapter->castingBefore($collection, $document); | ||
|
|
||
| $this->adapter->updateDocument($collection, $id, $document, $skipPermissionsUpdate); | ||
| $internalKeys = \array_column(self::INTERNAL_ATTRIBUTES, '$id'); | ||
| $allowedKeys = \array_flip(\array_merge($inputKeys, $internalKeys)); | ||
| $adapterDocument = new Document(\array_intersect_key($document->getArrayCopy(), $allowedKeys)); | ||
|
|
||
| $this->adapter->updateDocument($collection, $id, $adapterDocument, $skipPermissionsUpdate); | ||
|
Comment on lines
+6338
to
+6342
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This diverges from the previous behaviour where writing the full merged document meant the caller's return value always matched what was just persisted. Consider re-fetching the document (or merging in |
||
|
|
||
| $document = $this->adapter->castingAfter($collection, $document); | ||
|
|
||
|
|
||
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.
$inputKeysis captured here to restrict which columns the adapter writes. The existingtestUpdateDocumenttest always passes a fully-populated document, so$inputKeysequals the full attribute set and the new filtering is never exercised. A test that passes a document with only a subset of attributes and then asserts the omitted columns retain their previous DB values would prevent regressions in this new code path.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!