-
-
Notifications
You must be signed in to change notification settings - Fork 594
chore: update compare DB script data sorting logics #7428
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
Conversation
COMPARE TO
|
Name | Diff |
---|---|
.scripts/compare-database.js | 📈 +551 Bytes |
.scripts/compare-database.test.js | 📈 +8.74 KB |
package.json | 📈 +83 Bytes |
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.
Pull Request Overview
This PR enhances the database comparison script by introducing a deep sorting step for nested arrays and object properties before performing key-based sorting.
- Adds a
deepSort
function to normalize and sort array-typed data and object keys - Applies
deepSort
to each row’s data before invoking the existingbuildSortByKeys
comparator
Comments suppressed due to low confidence (3)
.scripts/compare-database.js:255
- Consider adding a JSDoc comment for
deepSort
to explain its purpose, input types, return format, and any edge‐case behavior.
// Deep sort function to handle arrays within data
.scripts/compare-database.js:283
- No unit tests cover the new
deepSort
logic; add tests that verify sorting of nested arrays and objects to guard against regressions.
data.map(deepSort).sort(buildSortByKeys(Object.keys(data[0] ?? {}))),
.scripts/compare-database.js:258
- Using
autoCompare
on arrays of potentially non-primitive values (e.g., nested objects) may produce inconsistent ordering; consider a stable comparator (such as comparingJSON.stringify
outputs) or a custom comparator for object arrays.
return obj.map(deepSort).sort(autoCompare);
65cbe6c
to
0134931
Compare
ac86650
to
b79a073
Compare
1bb23f3
to
feec365
Compare
feec365
to
c95c5d9
Compare
c95c5d9
to
72e240f
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.
LGTM
Summary
update compare DB script data sorting logics.
When comparing and sorting objects, our current key sorting approach might have some issues. We filter out keys whose values are of boolean type when apply sort on array elements.
Testing
We add test script for DB compare functions and add the test to CI.
Test with Cloud CI. See this PR.
Checklist
.changeset