Skip to content

Conversation

@rstam
Copy link
Contributor

@rstam rstam commented Jan 16, 2026

The problem is that our code to translate IndexOf comparisons assumes that the comparand is greater than or equal to zero but did not enforce that.

The behavior is undefined when the comparand is negative.

The short term fix is to throw an ExpressionNotSupportedException when the comparand is negative, which has the effect of causing the queries to be translated using $expr.

Queries using $expr are not very efficient. But with this PR at least they are correct so the bug is fixed.

See CSHARP-5844 for possible future work to translate these queries using regular expressions.

@rstam rstam requested a review from a team as a code owner January 16, 2026 16:49
@rstam rstam added the bug Fixes issues or unintended behavior. label Jan 16, 2026
Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes issues or unintended behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants