-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add getValueByPath() to the document #86
Conversation
Codecov Report
@@ Coverage Diff @@
## main #86 +/- ##
==========================================
+ Coverage 55.90% 56.05% +0.15%
==========================================
Files 92 92
Lines 14637 14695 +58
==========================================
+ Hits 8183 8238 +55
- Misses 6454 6457 +3
|
Task { | ||
let array = try? await target.getValueByPath(path: "$.") as? JSONObject | ||
|
||
XCTAssertTrue(array != nil) |
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.
Can we verify if the value is properly returned instead of checking if the array is not nil?
The getValueByPath()
method is used to retrieve values, such as doc.getValueByPath('$.obj.num')
, instead of using doc.getRoot().obj.num
. Therefore, it would be better to verify if the value is properly returned.
(Refer to the example using getValueByPath
in the js-sdk:
https://github.com/yorkie-team/yorkie-js-sdk/blob/395d052f2a6a3c1a5cef794a2e45b0312a63e945/public/multi.html#L169 )
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.
I added some Test code that verifies the value of getValueByPath() results.
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.
Thank you for the modification!
I have a question: Is it better to silently ignore the usage of a key containing .
instead of explicitly throwing an error?
root["$$...hello"] = [] as [Any]
// The key name can't contain "."
XCTAssertTrue(root["$$...hello"] == nil)
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.
I will add an assert and modify it so that you can know explicitly whether the wrong value was used in the development.
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.
Looks good to me :)
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist: