Skip to content

fix: enable case-insensitive array comparison in jsonLogic operators#28862

Draft
ousamabenyounes wants to merge 1 commit intocalcom:mainfrom
ousamabenyounes:fix/issue-jsonlogic-array
Draft

fix: enable case-insensitive array comparison in jsonLogic operators#28862
ousamabenyounes wants to merge 1 commit intocalcom:mainfrom
ousamabenyounes:fix/issue-jsonlogic-array

Conversation

@ousamabenyounes
Copy link
Copy Markdown

What does this PR do?

Fixes the ==, ===, !=, and !== operators in packages/lib/raqb/jsonLogic.ts to correctly compare arrays element-by-element instead of by JS reference equality.

Problem

JavaScript's == and === compare arrays by reference, so ["hello", "world"] === ["hello", "world"] is always false. This meant that multiselect "equals" comparisons in routing forms would never match, even when the selected values were identical.

A skipped test (should compare arrays case-insensitively) confirmed this bug.

Fix

Added an areEqual helper that:

  1. Normalizes both operands (lowercases strings)
  2. If both are arrays, compares length then each element
  3. Falls back to strict equality for non-arrays

Tests

  • Unskipped the existing it.skip test for array comparison on ==
  • Added new array comparison tests for ===, !==, and !=
  • All 23 tests pass (was 19 pass + 1 skip)
TZ=UTC yarn vitest run packages/lib/raqb/jsonLogic.test.ts

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

TZ=UTC yarn vitest run packages/lib/raqb/jsonLogic.test.ts

All 23 tests should pass, including the previously-skipped array comparison test.

Checklist

  • My code follows the style guidelines of this project
  • My changes generate no new warnings
  • My PR is small and focused (2 files)

Generated by Claude Code
Vibe coded by ousamabenyounes

The ==, ===, !=, and !== operators compared arrays by reference (JS
default), so two arrays with identical normalized values would always
mismatch. Added an areEqual helper that compares normalized arrays
element-by-element, and unskipped the previously-failing test.

Generated by Claude Code
Vibe coded by ousamabenyounes

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant