-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: Allow relation alias on create and update #1609
feat: Allow relation alias on create and update #1609
Conversation
Codecov ReportPatch coverage:
@@ Coverage Diff @@
## develop #1609 +/- ##
===========================================
+ Coverage 75.56% 75.65% +0.09%
===========================================
Files 199 200 +1
Lines 20769 20808 +39
===========================================
+ Hits 15693 15741 +48
+ Misses 3997 3990 -7
+ Partials 1079 1077 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 8 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
ff11461
to
9551e71
Compare
db/collection.go
Outdated
fieldKey, isAliasKey, fieldExists := c.tryGetFieldKey(primaryKey, k) | ||
// Overwrite the aliased key with the internal related object name. | ||
if isAliasKey { | ||
oldKey := k | ||
k = oldKey + request.RelatedObjectID | ||
doc.Fields()[k] = v | ||
delete(doc.Fields(), oldKey) |
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.
tip-for-reviewer: This implementation and some other parts or this commit were removed and implemented elsewhere while fixing a bug in the commit [PR(FIX): Squash the dockey verification + diff bug
]
41c4738
to
6eb9499
Compare
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.
Great work here Shahzad! Very nicely executed.
core/cid/cid.go
Outdated
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.
question: Should the date be changed to 2023?
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.
It's fine IMO
@@ -875,6 +866,7 @@ func (c *collection) save( | |||
|
|||
if val.IsDirty() { | |||
fieldKey, fieldExists := c.tryGetFieldKey(primaryKey, k) | |||
|
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.
question: Was this extra line accidental?
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.
It's when I undid the changes mentioned in the PR description lol.
Request: fmt.Sprintf( | ||
`mutation { | ||
update_Book(id: "%s", data: "{\"author_id\": \"%s\"}") { | ||
name | ||
} | ||
}`, | ||
bookKey, | ||
invalidAuthorKey, |
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.
thought (Out of scope): This should probably return an error no document for the given key exists
like it does on the 1-to-1.
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.
Yes I see a few tests before this PR that note adding that in. Not sure if there is a ticket for that yet.
Undo some changes that aren't needed with this approach.
modularize generation of cid such that it can be used in a consistent manner. i.e. blockstore or in client package
6eb9499
to
48e3f45
Compare
bug bash results: |
## Relevant issue(s) Resolves sourcenetwork#1279 ## Description Here are the main tasks that were done in this PR: - [x] Add some tests that are might not be directly related - [x] Before implementation add more tests for non-alias behavior while creating document. - [x] Add implementation for aliasing on related object link while creating document. - [x] Add 1-1 tests for aliasing on related object while creating document. - [x] Add 1-M tests for aliasing on related object while creating document. - [x] Before implementation add tests for non-alias behavior while updating document. - [x] Add implementation for aliasing on related object link while updating document. - [x] Add 1-1 tests for aliasing on related object while updating document. - [x] Add 1-M tests for aliasing on related object while updating document. In addition, I had to resolve a circular dependency but making the `core/cid.go` stuff it's own modular package. Refactored manual uses of `cid.Prefix` and dockey generation so that it's consistent.
Relevant issue(s)
Resolves #1279
Description
Here are the main tasks that were done in this PR:
In addition, I had to resolve a circular dependency but making the
core/cid.go
stuff it's own modular package. Refactored manual uses ofcid.Prefix
and dockey generation so that it's consistent.For Reviewers
PR(FIX): Squash the dockey verification + diff bug
undoes some work in the commitPR(CORE): Implement the alias logic for create
to fix a bug. Other than that should be "cleanish" history.How has this been tested?