fix(db-ivm): use row keys for stable ORDER BY tie-breaking #957
Mergedsamwillis(GitHub profile, opens in a new tab)merged 2 commits into
main fromrefs/pull/957/headmerged by samwillis(GitHub profile, opens in a new tab) kevin-dp(GitHub profile, opens in a new tab) approved these changes
@@ -261,7 +258,4 @@261258 super(id, inputA, output)262259 const limit = options.limit ?? Infinity263260 const offset = options.offset ?? 0264- const compareTaggedValues = (265- a: TaggedValue<K, T>,266- b: TaggedValue<K, T>267- ) => {261+ const compareKeyedValues = ([aKey, aVal]: [K, T], [bKey, bVal]: [K, T]) => {@@ -261,16 +258,12 @@261258 super(id, inputA, output)262259 const limit = options.limit ?? Infinity263260 const offset = options.offset ?? 0264- const compareTaggedValues = (265- a: TaggedValue<K, T>,266- b: TaggedValue<K, T>267- ) => {261+ const compareKeyedValues = ([aKey, aVal]: [K, T], [bKey, bVal]: [K, T]) => {268262 // First compare on the value269- const valueComparison = comparator(getVal(a), getVal(b))263+ const valueComparison = comparator(aVal, bVal)270264 if (valueComparison !== 0) {271265 return valueComparison272266 }273- // If the values are equal, compare on the tag (object identity)274- const tieBreakerA = getTag(a)275- const tieBreakerB = getTag(b)276- return tieBreakerA - tieBreakerB267+ // If the values are equal, use the row key as tie-breaker268+ // This provides stable, deterministic ordering since keys are string | number269+ if (aKey === bKey) return 0samwillis(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 97bd6c931c8d8b0ef3da785d0eacf56e0b7ac681
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR