Skip to content

fix: covers edge case interpretation in js runtime - #96

Merged
stalniy merged 3 commits into
mainfrom
fix/ucast-edge-cases
Nov 2, 2026
Merged

stalniy merged 3 commits into
mainfrom
fix/ucast-edge-cases

Conversation

@stalniy

@stalniy stalniy commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Why

to properly handle edge cases

What

Minor breaking changes which should not affect most of the users:

  • Ordering operators reject incompatible types by default instead of using
    JavaScript coercion. For example, { a: '2' } no longer matches
    { a: { $lt: 10 } }. Raw @ucast/js Date/number comparisons also stop
    matching; @ucast/mongo2js still normalizes Dates to numeric timestamps.
  • Ordering operators always return false when either operand is undefined,
    including missing fields, without calling custom comparators. Selecting
    the legacy compare function does not restore this behavior.
  • eq(ITSELF, null) now matches null and [null], and no longer matches {},
    [{}], or [[null]]. The corresponding ne results change inversely.
  • Projected exists(false) now requires every array element to lack the
    property. Mixed present/missing arrays stop matching, while empty arrays
    start matching.
  • exists(ITSELF, false) now returns false for defined inputs and true for
    undefined, reversing its previous results.
  • Array projection skips null and undefined elements before calling custom
    getters, so getters can no longer supply values for those elements.
  • JsInterpretationOptions.compare can now return null. Consumers of its
    result, including custom interpreters, must handle incomparable values
    instead of assuming the result is always -1, 0, or 1.

@stalniy
stalniy force-pushed the fix/ucast-edge-cases branch 2 times, most recently from db8a93f to ee7d4c1 Compare November 2, 2026 10:12
@stalniy
stalniy force-pushed the fix/ucast-edge-cases branch 2 times, most recently from cca943c to 8f950f0 Compare November 2, 2026 10:55
BREAKING CHANGE: query matching and comparator result types change in
@ucast/js and @ucast/mongo2js:

- Ordering operators reject incompatible types by default instead of using
  JavaScript coercion. For example, { a: '2' } no longer matches
  { a: { $lt: 10 } }. Raw @ucast/js Date/number comparisons also stop
  matching; @ucast/mongo2js still normalizes Dates to numeric timestamps.
- Ordering operators always return false when either operand is undefined,
  including missing fields, without calling custom comparators. Selecting
  the legacy compare function does not restore this behavior.
- eq(ITSELF, null) now matches null and [null], and no longer matches {},
  [{}], or [[null]]. The corresponding ne results change inversely.
- Projected exists(false) now requires every array element to lack the
  property. Mixed present/missing arrays stop matching, while empty arrays
  start matching.
- exists(ITSELF, false) now returns false for defined inputs and true for
  undefined, reversing its previous results.
- Array projection skips null and undefined elements before calling custom
  getters, so getters can no longer supply values for those elements.
- JsInterpretationOptions.compare can now return null. Consumers of its
  result, including custom interpreters, must handle incomparable values
  instead of assuming the result is always -1, 0, or 1.
@stalniy
stalniy force-pushed the fix/ucast-edge-cases branch from 8f950f0 to 6e3ebab Compare November 2, 2026 11:01
@stalniy
stalniy merged commit fff25a1 into main Nov 2, 2026
4 checks passed
@stalniy
stalniy deleted the fix/ucast-edge-cases branch November 2, 2026 11:06
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
stalniy added a commit that referenced this pull request Nov 6, 2026
stalniy added a commit that referenced this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant