Skip to content

Fixes NotEquals filter for null and typed values - #34

Open
arotolo wants to merge 2 commits into
mainfrom
fix/not-equals-null
Open

arotolo wants to merge 2 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.

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