Skip to content

Fixes NotEquals filter for null and typed values - #34

Merged
michaelstonis merged 5 commits into
mainfrom
fix/not-equals-null
Oct 5, 2026
Merged

michaelstonis merged 5 commits into
mainfrom
fix/not-equals-null

Conversation

@arotolo

@arotolo arotolo commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Corrects the behavior of the NotEquals filter for various scenarios:

  • Handles null values correctly: Previously, Filter(NotEquals, x => x.Member, null) for scalar paths generated JSON_EXTRACT(...) <> NULL, which always evaluates to false in SQL. The filter now emits IS NOT NULL, ensuring that the "member is present" test returns the expected rows, consistent with list-member paths and Equals for nulls.
  • Compares typed values consistently: Addresses issues where NotEquals with DateTime, DateTimeOffset, or numeric values could incorrectly include excluded rows.
    • DateTime and DateTimeOffset values were bound as culture-formatted text, not the serializer's ISO format.
    • Numeric members lacked the necessary CAST(… as NUMERIC) for comparison.
      These operators now share a unified type dispatch logic for both scalar and list-member paths, guaranteeing values are bound and cast correctly (e.g., DateTime uses serializer format, numeric values are cast to NUMERIC), ensuring accurate exclusions.

Introduces new unit tests to thoroughly cover NotEquals behavior for null, date-time, and numeric values on both scalar and list-member properties.

Copilot AI lite review requested due to automatic review settings September 24, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Ensure date-time comparisons use the serializer’s actual representation and add execution-based list-member coverage.

Review effort: Lite
Findings: None

What changed in this PR

Fixes NotEquals filtering for null, date-time, and numeric values across scalar and list-member paths.

Changes:

  • Adds IS NOT NULL handling for null comparisons.
  • Applies typed comparisons and numeric casts consistently.
  • Adds regression tests and changelog documentation.
File Review summary
TychoDB/​FilterBuilder.cs Centralizes comparison rendering. Custom date-time formats may not match serializer output for scalar and list-member comparisons.
TychoDB.UnitTests/​NotEqualsValueTests.cs Covers typed values, but list-member cases verify SQL rather than execution results.
TychoDB.UnitTests/​NotEqualsNullTests.cs Covers null and presence semantics.
TychoDB.UnitTests/​NotEqualsDateTimeTests.cs Covers date-time exclusions.
CHANGELOG.md Documents the fixes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

michaelstonis and others added 3 commits October 5, 2026 13:26
Equals and NotEquals sent every non-null value on a DateTime path through
GetDateTimeString, which returns an empty string for anything that is not a
DateTime or DateTimeOffset. NotEquals with an already formatted string then
rendered <> '' and returned every row with a date, where v5.3.0 returned
the right rows. The date branch is now taken only for an actual date; other
values are bound as given.

Adds scalar and list-member tests for a text value on a date path, the
changelog notes for it and for NaN on numeric members, and dates the 5.3.0
changelog section.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Resolves the list-member NotEquals case in favor of AppendListMemberEquality,
which already carries the date branch main added there, and keeps main's
JSON_EACH guard. The two 5.3.1 changelog sections are combined, with main's
NotEquals-date bullet folded into the entry that already covers it.

Now that list-member filters no longer raise malformed JSON, adds a test
that executes the list-member NotEquals cases instead of only rendering them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@michaelstonis
michaelstonis merged commit 899e504 into main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants