Skip to content

fix(postgresql): typed filters compare chars as chars and translate HasValue and Value - #122

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/80-char-hasvalue-scalar-members
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/80-char-hasvalue-scalar-members

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #80

Stacked on #121 (the parity sweep); merge that first.

Problem

  • x => x.Grade == 'A' on a char: C# compares the char's code, so the translator rendered "Grade" = 65, and PostgreSQL refused the migration at apply (operator does not exist: character = integer). Also inside a coalesce ((x.Backup ?? 'B') == 'A') and on a ToJson() member.
  • x => !x.RevokedAt.HasValue, x => x.Count.Value > 5, x => x.CreatedAt.Year > 2020: accepted at the declaration as the paths {RevokedAt.HasValue}, {Count.Value}, {CreatedAt.Year}, then migrations add threw Could not resolve property path. The same in typed expression indexes. The issue's scope was widened from HasValue to every member of a scalar type, which the sweep showed fail the same way.

Change

Tests

  • New in NpgsqlTypedFilterTests: char comparisons render a char literal; HasValue/Value translate; CreatedAt.Year, RevokedAt.Value.Month and CreatedAt.Day are refused at the declaration.
  • With the translator change reverted, those three fail and the parity sweep fails 274 rows.
  • Full suite 420/420 including the PostgreSQL integration suite, whose live sweep now runs the char, HasValue and .Value rows against PostgreSQL 18.

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working stacked Base is another open PR; merge in order, CI does not run until it targets main severity/low Cosmetic, message or documentation-level difference package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL area/indexes Complex-property, composite, unique and filtered indexes area/expression-indexes Expression, typed LINQ and JSON member indexes labels Oct 20, 2026
…asValue and Value (#80)

C# compares a char as its code, so x.Grade == 'A' arrived as
Convert(x.Grade) == 65 and rendered "Grade" = 65, which PostgreSQL
refuses at apply. HasValue, Value and any other member of a scalar type
(CreatedAt.Year) passed the declaration as a property path and failed at
migrations add with "Could not resolve property path".

A constant compared with a converted char is rendered as the char it was
written as. Nullable<T>.Value is the column and HasValue its null check
(IS NOT NULL, pushed into IS NULL under a negation), both as EF Core
renders them, and every other member of a scalar type is refused at the
declaration.

Verified with the translator change reverted: the three new tests fail,
and the parity sweep fails 274 rows, which this change removes from
waivers.txt. The 36 rows left there are negated .Value comparisons,
shaped as the other negated nullable comparisons are (#118).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/80-char-hasvalue-scalar-members branch from 472139d to cfa3ed0 Compare October 20, 2026 06:35
@CaffeinatedCoder
CaffeinatedCoder force-pushed the tests/101-translator-parity-sweep branch from 5549f45 to bf545be Compare October 20, 2026 06:35
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from tests/101-translator-parity-sweep to main October 20, 2026 06:56
# Conflicts:
#	CHANGELOG.md
#	src/EFCore.ComplexIndexes.PostgreSQL/CHANGELOG.md
@CaffeinatedCoder
CaffeinatedCoder merged commit 7133f9a into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/80-char-hasvalue-scalar-members branch October 20, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/expression-indexes Expression, typed LINQ and JSON member indexes area/indexes Complex-property, composite, unique and filtered indexes bug Something isn't working package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL severity/low Cosmetic, message or documentation-level difference stacked Base is another open PR; merge in order, CI does not run until it targets main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typed filters: char comparisons render an integer, and HasValue and other scalar members fail at migrations add, not at the declaration

1 participant