Skip to content

SQLite: add JsonValueReaderWriter for Half#38492

Merged
AndriySvyryd merged 2 commits into
mainfrom
copilot/add-sqlitejsonhalfreaderwriter
Jun 29, 2026
Merged

SQLite: add JsonValueReaderWriter for Half#38492
AndriySvyryd merged 2 commits into
mainfrom
copilot/add-sqlitejsonhalfreaderwriter

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #37481

SqliteHalfTypeMapping had no JsonValueReaderWriter, causing any JSON mapping scenario (owned entity/primitive collection stored as JSON) to throw MissingJsonValueReaderWriter at runtime.

Changes

  • SqliteJsonHalfReaderWriter (new) — SQLite-specific JsonValueReaderWriter<Half> that round-trips through float, matching SQLite's REAL storage. Follows the same pattern as SqliteJsonDecimalReaderWriter / SqliteJsonGuidReaderWriter.
  • SqliteHalfTypeMapping — passes SqliteJsonHalfReaderWriter.Instance via CoreTypeMappingParameters(jsonValueReaderWriter: ...).
  • SQLite functional test coverage — added Can_read_write_Half_JSON_values to JsonTypesSqliteTest to 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 → Half is lossless.

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 AI requested a review from AndriySvyryd June 26, 2026 17:55
@AndriySvyryd AndriySvyryd requested a review from Copilot June 26, 2026 18:35
Comment thread src/EFCore.Sqlite.Core/Storage/Internal/SqliteHalfTypeMapping.cs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-specific JsonValueReaderWriter<Half> that serializes/deserializes via float.
  • Wires the new reader/writer into SqliteHalfTypeMapping via CoreTypeMappingParameters(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.

Comment thread src/EFCore.Sqlite.Core/Storage/Internal/SqliteHalfTypeMapping.cs
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd June 26, 2026 18:48
@AndriySvyryd AndriySvyryd marked this pull request as ready for review June 26, 2026 20:55
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner June 26, 2026 20:55
Copilot AI review requested due to automatic review settings June 26, 2026 20:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@AndriySvyryd AndriySvyryd requested a review from cincuranet June 26, 2026 21:21
@AndriySvyryd AndriySvyryd merged commit 2279bff into main Jun 29, 2026
16 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/add-sqlitejsonhalfreaderwriter branch June 29, 2026 18:49
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants