-
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 #35328
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Jiri Cincura ↹ <[email protected]>
…reate json reader writer
src/EFCore.Sqlite.Core/Storage/Internal/SqlliteHalfTypeMapping.cs
Outdated
Show resolved
Hide resolved
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
protected override string GenerateNonNullSqlLiteral(object value) | ||
=> new DoubleTypeMapping(StoreType).GenerateSqlLiteral((double)(Half)value); |
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 needs specific implementation.
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 did you mean specific? If value is null, this will generate an exception?
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 mean not relying on DoubleTypeMapping
, but rather having specific implementation here.
/// </summary> | ||
public HalfTypeMapping( | ||
string storeType, | ||
DbType? dbType = System.Data.DbType.Single) |
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.
System.Data.DbType.Single
is not correct here. Given that there's no Half
in System.Data.DbType
, I think we can have just specific implementation for SQLite.
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.
Something like new("Real")?
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.
No. I think the HalfTypeMapping
should not exist. Simply remove it and have only SQLite implementation.
@@ -176,6 +177,7 @@ public void Does_mappings_for_store_type(string storeType, Type clrType, DbType? | |||
[InlineData("REAL", typeof(float), DbType.Single)] | |||
[InlineData("UNREALISTIC", typeof(float), DbType.Single)] | |||
[InlineData("RUBBISH", typeof(float), DbType.Single)] | |||
[InlineData("RUBBISH", typeof(Half?), DbType.Single)] |
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.
Looks like you're missing some values here for completeness.
Sorry for taking so long to respond |
/// </summary> | ||
public HalfTypeMapping( | ||
string storeType, | ||
DbType? dbType = System.Data.DbType.Single) |
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.
No. I think the HalfTypeMapping
should not exist. Simply remove it and have only SQLite implementation.
@@ -72,6 +72,7 @@ protected override DbCommand CreateTestCommand() | |||
[InlineData(typeof(SqliteDecimalTypeMapping), typeof(decimal))] | |||
[InlineData(typeof(SqliteGuidTypeMapping), typeof(Guid))] | |||
[InlineData(typeof(SqliteULongTypeMapping), typeof(ulong))] | |||
[InlineData(typeof(EntityFrameworkCore.Sqlite.Storage.Internal.SqliteHalfTypeMapping), typeof(Half))] |
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.
Full namespace not needed.
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
protected override string GenerateNonNullSqlLiteral(object value) | ||
=> new DoubleTypeMapping(StoreType).GenerateSqlLiteral((double)(Half)value); |
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 mean not relying on DoubleTypeMapping
, but rather having specific implementation here.
@@ -50,6 +50,7 @@ public class SqliteTypeMappingSourceTest : RelationalTypeMappingSourceTestBase | |||
[InlineData("TEXT", typeof(TimeSpan?), DbType.Time)] | |||
[InlineData("TEXT", typeof(decimal?), DbType.Decimal)] | |||
[InlineData("REAL", typeof(float?), DbType.Single)] | |||
[InlineData("REAL", typeof(Half), DbType.Single)] |
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.
[InlineData("REAL", typeof(Half), DbType.Single)] | |
[InlineData("REAL", typeof(Half?), DbType.Single)] |
@@ -176,6 +177,7 @@ public void Does_mappings_for_store_type(string storeType, Type clrType, DbType? | |||
[InlineData("REAL", typeof(float), DbType.Single)] | |||
[InlineData("UNREALISTIC", typeof(float), DbType.Single)] | |||
[InlineData("RUBBISH", typeof(float), DbType.Single)] | |||
[InlineData("RUBBISH", typeof(Half), DbType.Single)] |
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.
Still missing i.e. UNREALISTIC
case.
Fixes #30931
Also I want to discuss with team, what shall I change in migration and compiled models, because I a little bit misunderstanding