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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

darcyYe
Copy link
Contributor

@darcyYe darcyYe commented Jun 5, 2025

Summary

update compare DB script data sorting logics.

  1. Previously, if the value in the data is array, since we do not have existing logic to apply sorting on array-typed data, the DB comparison could throw when the array have the same value but in different order.
  2. Trim DB functions before comparing by lines.

Testing

Test with Cloud CI.

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 ⚠️ 📈 +11.16 KB

Diff by File
Name Diff
.scripts/compare-database.js 📈 +2.29 KB
.scripts/compare-database.test.js 📈 +8.79 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 4 times, most recently from d13c4f4 to d094da9 Compare June 9, 2025 13:35
@darcyYe darcyYe force-pushed the yemq-update-compare-db-script-sorting-logic branch from ac86650 to b79a073 Compare June 10, 2025 08:56
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.

1 participant