Repository navigation
fix: read a filter value into a nullable property instead of throwing - #27
Merged
Merged
Conversation
Filtering by any nullable property failed before a row was read: InvalidCastException: Invalid cast from 'System.String' to 'System.Nullable`1[[System.Int64, ...]]' GetFilterValue switches on Type.GetTypeCode(resultType), and that answers Object for Nullable<long> rather than Int64, so every nullable type fell through to the default branch and Convert.ChangeType -- which cannot produce a Nullable<T> at all. IsEnum is false for Nullable<TEnum> for the same reason, so nullable enums went the same way. Nullable.GetUnderlyingType unwraps it once, at the top, and the rest of the method reasons about the underlying type. Returning the underlying value boxed is what callers already expect: RunFilter converts the constant to the member's own type, which is how a non-nullable enum has always arrived as its Int32. Measured against 1.13.2 with the payload that reported it, long?, int?, bool?, decimal?, double?, DateTime? and nullable enums every one threw; all of them now return the value, from a JSON number and from a JSON string alike. The non-nullable cases and string are byte for byte what they were. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🎉 This PR is included in version 1.13.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Filtering by any nullable property failed before a row was read:
InvalidCastException: Invalid cast from 'System.String' to
'System.Nullable`1[[System.Int64, ...]]'
GetFilterValue switches on Type.GetTypeCode(resultType), and that answers Object for Nullable rather than Int64, so every nullable type fell through to the default branch and Convert.ChangeType -- which cannot produce a Nullable at all. IsEnum is false for Nullable for the same reason, so nullable enums went the same way.
Nullable.GetUnderlyingType unwraps it once, at the top, and the rest of the method reasons about the underlying type. Returning the underlying value boxed is what callers already expect: RunFilter converts the constant to the member's own type, which is how a non-nullable enum has always arrived as its Int32.
Measured against 1.13.2 with the payload that reported it, long?, int?, bool?, decimal?, double?, DateTime? and nullable enums every one threw; all of them now return the value, from a JSON number and from a JSON string alike. The non-nullable cases and string are byte for byte what they were.