SQLite: add JsonValueReaderWriter for Half#38492
Merged
Merged
Conversation
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot
AI
changed the title
Add SqliteJsonHalfReaderWriter to fix JSON mapping for Half in SQLite
SQLite: add JsonValueReaderWriter for Half
Jun 26, 2026
Copilot created this pull request from a session on behalf of
AndriySvyryd
June 26, 2026 17:55
View session
There was a problem hiding this comment.
Pull request overview
This PR addresses a gap in the SQLite provider’s JSON type-mapping support: Half values mapped into JSON (e.g., owned types / primitive collections stored as JSON) previously failed at runtime due to a missing JsonValueReaderWriter.
Changes:
- Adds
SqliteJsonHalfReaderWriter, a SQLite-specificJsonValueReaderWriter<Half>that serializes/deserializes viafloat. - Wires the new reader/writer into
SqliteHalfTypeMappingviaCoreTypeMappingParameters(jsonValueReaderWriter: ...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/EFCore.Sqlite.Core/Storage/Json/Internal/SqliteJsonHalfReaderWriter.cs | Introduces a JSON reader/writer for Half using float as the intermediate representation. |
| src/EFCore.Sqlite.Core/Storage/Internal/SqliteHalfTypeMapping.cs | Registers the new JSON reader/writer so JSON mapping scenarios for Half no longer throw at runtime. |
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
cincuranet
approved these changes
Jun 29, 2026
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.
Follow-up to #37481
SqliteHalfTypeMappinghad noJsonValueReaderWriter, causing any JSON mapping scenario (owned entity/primitive collection stored as JSON) to throwMissingJsonValueReaderWriterat runtime.Changes
SqliteJsonHalfReaderWriter(new) — SQLite-specificJsonValueReaderWriter<Half>that round-trips throughfloat, matching SQLite's REAL storage. Follows the same pattern asSqliteJsonDecimalReaderWriter/SqliteJsonGuidReaderWriter.SqliteHalfTypeMapping— passesSqliteJsonHalfReaderWriter.InstanceviaCoreTypeMappingParameters(jsonValueReaderWriter: ...).Can_read_write_Half_JSON_valuestoJsonTypesSqliteTestto validate Half JSON round-tripping and prevent regressions.Half has ~3.3 decimal digits of precision, well within float's ~7.2, so
Half → float → JSON number → float → Halfis lossless.