Skip to content

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

Merged
merged 7 commits into from
Jun 24, 2025

Conversation

darcyYe
Copy link
Contributor

@darcyYe darcyYe commented Jun 5, 2025

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
  • unit tests
  • integration tests
  • necessary TSDoc comments

@darcyYe darcyYe requested review from a team and Copilot June 5, 2025 05:20
Copy link

github-actions bot commented Jun 5, 2025

COMPARE TO master

Total Size Diff 📈 +9.36 KB

Diff by File
Name Diff
.scripts/compare-database.js 📈 +551 Bytes
.scripts/compare-database.test.js 📈 +8.74 KB
package.json 📈 +83 Bytes

Copy link
Contributor

@Copilot Copilot AI left a 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 existing buildSortByKeys 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 comparing JSON.stringify outputs) or a custom comparator for object arrays.
return obj.map(deepSort).sort(autoCompare);

@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch from 65cbe6c to 0134931 Compare June 6, 2025 02:52
@github-actions github-actions bot added the size/l label Jun 6, 2025
@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch 5 times, most recently from ac86650 to b79a073 Compare June 10, 2025 08:56
@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch 2 times, most recently from 1bb23f3 to feec365 Compare June 23, 2025 02:41
@simeng-li simeng-li removed the size/l label Jun 24, 2025
@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch from feec365 to c95c5d9 Compare June 24, 2025 08:20
@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch from c95c5d9 to 72e240f Compare June 24, 2025 08:23
Copy link
Contributor

@simeng-li simeng-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@darcyYe darcyYe merged commit 15f290a into master Jun 24, 2025
38 of 44 checks passed
@darcyYe darcyYe deleted the yemq-update-compare-db-script-sorting-logic branch June 24, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants