Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hashing of IList constants in SqlConstantExpression #35487

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

ranma42
Copy link
Contributor

@ranma42 ranma42 commented Jan 16, 2025

Since the Equals method performs deep comparison of IList values, using their GetHashCode directly is generally not valid.
Instead, their Count is a safe approximation.

Fixes #35372

These tests check that:
 - `Equals` performs a deep comparison of the wrapped constant
 - `GetHashCode` is consistent with `Equals`, specifically that if two
   SqlConstantExpression are `Equals`, they both have the same `GetHashCode`
Since the `Equals` method performs deep comparison of `IList` values, using
their `GetHashCode` directly is generally not valid. Instead, their `Count` is a
safe approximation.

Fixes dotnet#35372
@ranma42 ranma42 requested a review from a team as a code owner January 16, 2025 20:11
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks @ranma42!

@roji roji merged commit 707fb5b into dotnet:main Jan 16, 2025
7 checks passed
@ranma42 ranma42 deleted the fix-35372 branch January 17, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Equals/GetHashCode methods in SqlConstantExpression
2 participants