fix(query-devtools/utils): make 'last updated' sort return 0 for queries with equal 'dataUpdatedAt' to follow the standard comparator contract#10812
Conversation
…ies with equal 'dataUpdatedAt' to follow the standard comparator contract
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR fixes a bug in the query DevTools where the "last updated" sort comparator was not properly handling equal timestamps. The implementation is corrected to return 0 when two queries have the same ChangesDate Sort Equality Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit a7eccf3
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview2 package(s) bumped directly, 23 bumped as dependents. 🟩 Patch bumps
|
size-limit report 📦
|
🎯 Changes
The devtools
'last updated'sort (dateSortinutils.tsx:104-105) was implemented as a binary comparator:This breaks the standard
Array.prototype.sortcomparator contract for equal inputs — fora.dataUpdatedAt === b.dataUpdatedAt, the function still returns-1instead of0, so V8's stable sort cannot preserve the input order between two queries that were updated at the same millisecond. The implementation also relies on a strict<check, which means a futuredataUpdatedAtofNaNwould silently fall into the-1branch.Rewrite
dateSortto the canonical descending comparator (most recently updated first) using a single subtraction plus an explicit ternary, so the function returns-1,0, or1:0), so stable sort keeps their relative input order.NaN/Infinityinputs fall through to the0branch instead of returning a non--1/0/1value, which keeps the comparator deterministic.Also add an
expect(dateSort(a, b)).toBe(0)regression case toutils.test.tsso the equal-timestamp branch fails loudly if the binary form is reintroduced. The existing.toBe(1)/.toBe(-1)assertions still hold because the new implementation still emits-1/1for the unequal cases.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit