Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2 #362 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 26 27 +1
Lines 757 790 +33
=========================================
+ Hits 757 790 +33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
06ede2e to
981dace
Compare
peterdesmet
left a comment
There was a problem hiding this comment.
This PR:
-
Sets
$schemaas first property, using a new helper functionappend_with_attrs(), with the goal of solving #358. -
Adds a public
append()function (using the new helper), with the goal of solving #198.
Those are very different functionalities and I find this to complex to review in one PR.
Solution
A stacked PR would have worked here, but since we can't rewrite that, I did the following:
-
From
v2, create new branchdollar-schema-firstand checkout the relevant files from this PR. Commit with @PietrH as co-author created PR #366 -
From
v2, create new branchappend-functionand checkout the relevant files from this PR. Commit with @PietrH as co-author created PR #365
I will review those separately. The helper first, since that one is needed for 2.0.0. The second one can wait.
Fixes #198
I ended up implementing a generic S3 method for
append()which allowed me to set a S3 method forappend.datapackage(). However, sinceresourceobjects don't have a custom class, I had to implement a helper to append lists while retaining attributes. Some attributes can never be kept while appending, such as names (because they depend on the length of the object staying the same, which is not the case forappend()). Things like dimnames would also break this custom append helper, as I only added an exception for names.Converting
append()to a generic S3 method will result in a message when loading frictionless:This can be avoided by not using S3 dispatch at all, and using the internal helper for packages as well. But then users will not be able to call
append()on a datapackage without dropping attributes.Furthermore, I re-added tests for the location of the
$schemanode inupgrade_resource()andupgrade_descriptor(). Both use the same append helper code, butupgrade_descriptor()uses the generic, anywhere in the package you can callappend()on a datapackage object, if you want to append a list without dropping the object class or attributes, you need to remember to useappend_with_attrs(). This also has the advantage that users can now callappend()on a datapackage object, and it'll just work. The same is not true for resources.I started work on adding a custom class for resources, but will leave that exercise for the future.