-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Adding Half type support for SqlLite #35193
Conversation
@dotnet-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. This looks good, just some small details to iron out.
src/EFCore.Sqlite.Core/Storage/Internal/SqliteHalfTypeMapping.cs
Outdated
Show resolved
Hide resolved
=> "'" + HalfFormatConst + "'"; | ||
|
||
/// <inheritdoc/> | ||
protected override string GenerateNonNullSqlLiteral(object value) => Convert.ToDouble((Half)value).ToString("R"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be here, given we have proper implementation for SqlLiteralFormatString
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Co-authored-by: Jiri Cincura ↹ <[email protected]>
@@ -82,6 +82,9 @@ private static readonly HashSet<string> SpatialiteTypes | |||
{ typeof(decimal), SqliteDecimalTypeMapping.Default }, | |||
{ typeof(double), Real }, | |||
{ typeof(float), new FloatTypeMapping(RealTypeName) }, | |||
#if NET5_0_OR_GREATER | |||
{ typeof(Half), new FloatTypeMapping(RealTypeName) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be SqliteHalfMapping, not FloatTypeMapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I missed that.
protected override string SqlLiteralFormatString | ||
=> "'" + HalfFormatConst + "'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this doesn't look right. It will store them as TEXT values, not REAL. I think this whole implementation should look more like FloatTypeMapping and DoubleTypeMapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should this be added to Relational instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean as Relation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In EFCore.Relaional (next to the ones for float and double). This would allow other providers to reuse them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thanks. I re-wrote from sqlhalftypemapping to simple half type mapping
…reate json reader writer
Looking at it with fresh eyes now and also after talking with the team... This should be split into two PRs. First would handle only the |
@cincuranet , so I need to create two issues. First only for sqllite and second for full ef? |
Yeah, the Microsoft.Data.Sqlite changes here look ready to go to me (FWIW), but there's more to consider on the EF side like value converters, compiled models, migrations, etc. |
Fixes #30931