Skip to content

Add Half type support for SQLite (#30931)#37480

Closed
kimjaejung96 wants to merge 3 commits into
dotnet:mainfrom
kimjaejung96:users/kimjaejung96/implement-json-exists-31136
Closed

Add Half type support for SQLite (#30931)#37480
kimjaejung96 wants to merge 3 commits into
dotnet:mainfrom
kimjaejung96:users/kimjaejung96/implement-json-exists-31136

Conversation

@kimjaejung96
Copy link
Copy Markdown

  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
  • Tests for the changes have been added (for bug fixes / features)
  • Code follows the same patterns and style as existing code in this repo

Summary

Add Half (16-bit floating point) type support for Microsoft.Data.Sqlite and EF Core SQLite provider.

Fixes #30931

Changes

Microsoft.Data.Sqlite (ADO.NET layer)

File Change
SqliteValueReader.cs Add GetFieldValue<Half> support
SqliteValueBinder.cs Add Half binding + type mapping

EF Core SQLite Provider

File Change
SqliteHalfTypeMapping.cs New - SQLite-specific type mapping
SqliteTypeMappingSource.cs Register Half mapping

Tests

File Change
SqliteDataReaderTest.cs Half read/write tests
SqliteTypeMappingSourceTest.cs CLR/Store type mapping tests (including UNREALISTIC)
SqliteTypeMappingTest.cs SQL literal generation + clone test

Design Notes

Based on #35328 feedback:

  1. SQLite-specific only - No changes to EFCore.Relational (no HalfTypeMapping in common layer)
  2. No DbType - System.Data.DbType has no Half value, so DbType is null
  3. Float pattern - Follows existing float implementation (read via GetFloat(), bind via BindDouble())
  4. Conditional compilation - Uses #if NET6_0_OR_GREATER for netstandard2.0 compatibility

- Use primary constructor in SqlServerJsonFunctionTranslator
- Use expression-bodied method with ternary operator
- Use trimming-friendly method matching (name + declaring type instead of reflection)
- Remove [NotParameterized] from path parameter
- Remove RelationalDbFunctionsTest.cs (throw tests not useful)
- Replace literal-only test with column-based test (JsonExists_with_column)
- Add Half support in SqliteValueReader.GetFieldValue<T>
- Add Half binding in SqliteValueBinder
- Add SqliteHalfTypeMapping for EF Core SQLite provider
- SQLite-specific implementation only (per maintainer feedback)
- Use REAL store type, DbType is null (no DbType.Half exists)

Fixes dotnet#30931
@kimjaejung96 kimjaejung96 requested a review from a team as a code owner January 11, 2026 05:56
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.

Microsoft.Data.Sqlite: Support Half

1 participant